I ordered a 16MHz Pro Mini from Aliexpress (I know, I know, but I did) and they sent me one with a 328PB. I haven't tried to program it, but I assume my portable IDE v1.8.8 will balk on the signature. What I'd like to do is the minimum needed to flash one sketch to it. I don't need to use the extra features of the 328PB, and I really would like to avoid adding MiniCore or anything major like that. In the past I added the "breadboard" 328P in a new boards.text file in Portable/Sketchbook/Hardware, but of course it's still a 328P. Can someone guide me on how to add the 328PB to the IDE so I can program it like a 328P but with the right signature and bootloader?
Well I was going to say the minimum is just to install MiniCore. Is there an issue with adding MiniCore or upgrading to Arduino 1.8.19 and then adding MiniCore? Did you know Arduino 1.8.19 can be installed and used in portable mode? So if you want a completely independent Arduino 1.8.19 loaded up with whatever cores and libraries you want in it, it won’t result in messing with your legacy 1.8.8 installation. https://docs.arduino.cc/software/ide-v1/tutorials/PortableIDE/
I would be interested to know your buying experience with this Pro Mini on Aliexpress, because I order stuff on Aliexpress but it has been a while since I ordered a Pro Mini. The last time I ordered one of those was before the PB version was pushed really hard by the sellers. Do you think you were deceived and sent something you didn’t order, or did you have a choice in the small print or selections you missed?
Why not MiniCore? It seems to have been part of the solution going back to 2016.
I believe they ship the boards with a bootloader that causes it to provide the ATmega328P chip signature. If so, you can just configure Arduino IDE for the standard Pro Mini board.
Try this:
- Connect the Pro Mini to your computer via a USB to serial adapter module.
- Select Tools > Board > Arduino AVR Boards > Arduino Pro or Pro Mini from the Arduino IDE menus.
- Select Tools > Processor > ATmega328P (5V, 16 MHz) from the Arduino IDE menus.
- Select the port of the USB to serial adapter module from Arduino IDE's Tools > Port menu.
Now try uploading a sketch to the board. Hopefully everything will work as expected.
When I started here we had IDE 0023 and in the friendly pages like Hacking there was a part on bootloading blank factory AVR’s to use in the Uno R3 socket (pin & features compatible 328/168/88/48 with most to least memory)….
and it only covered 328P-A and I bought way cheaper 328P-PU chips.
So I hacked the IDE 328P core file ID bytes and it worked just fine.
Two old posts on the Gammon forum, one asks about changing the clock on a 328PB with the Program Bootloader Sketch and Nick replied you can by changing the sketch (note: that would require an upload). That sketch may cover many 328P variants.
Well, I really tried to order the right thing. And in fact the package the Pro Mini came in says "N24 / 328P 5V 16MHz". But the marking on the chip clearly says 328PB. Well, judge for yourself:
https://www.aliexpress.us/item/3256809225264759.html
I guess they just consider them to be interchangeable.
Anyway, I found a link to add to the boards manager preference, and it appears to have worked. So I'm good on the original question.
It also occurred to me that after compiling the sketch for the 328P, I could have used Arduino-as-ISP and AVRDudess to write the HEX file to the chip. Maybe even the sketch and the bootloader.
Edit: I should say that I need to solder the header pins and see if it works as a 328P as @ptillisch suggests. And I need to confirm the crystal frequency. It's marked "AA", which doesn't tell me much.
Edit2: Also, I ordered on the 14th, and it arrived on the 20th. That's unheard of for Aliexpress.
On that Aliexpress page the final Selling Point is
-
Atmega328P-AU Microcontroller:Equipped with Atmel Atmega328P-AU microcontroller for reliable Arduino Pro Mini 328 performance.
Yah. Sure. Interchangeable. Marketspeak alert.
The 328PB has 27 IO lines and 2x(serial,I2C,SPI,TWI) and Microchip rated it for automotive use. That’s respectable reach out and touch for a 328.
Maybe the marketers don’t know what gets shipped? The 328P is not pin-compatible with the 328PB.
The PB is essentially backward compatible with the 328P. The extra IO pins show up on a pair of power pins (PE0/1 on pins 3/6) and the previous "analog only" pins (PE2/3 on pins 19/22) - if you leave them in input modes, and only access the 328P functions, it'll be fine. (The second serial port is on the same pins as the first SPI port, so it's not as useful as it might be - you can't access all the doubled peripherals at the same time.)
There's also a couple extra timers on the PB, so you could have up to 10 PWMs...
The 328PB is cheaper than the 328P (or the 328, for that matter.) I suspect that the various "derivative" vendors didn't even change their PCBs, but just switched chips.
The other way is less likely to work.
It turns out @ptillisch is right. This Pro Mini programs as a 328P in the IDE. That's despite the fact that the signature is 1E 85 16, which is the PB signature. So maybe they just flashed the 328P bootloader into this chip. When I have more time, I'll use AVRdudess to extract the chip's contents and see if the bootloader matches the 328P bootloader exactly, or if not, whether it just differs in a few bytes.
But now, with this existing bootloader, I won't be able to use any of the PB's extra features. I can write code as if it's a PB, and if I set the board to the PB, it will compile, but won't upload because there's a signature mismatch. So I probably should get out my Arduino-as-ISP and flash the 328PB bootloader to it, whatever that is.
I also ran Kevin Darah's "Is this a counterfeit" sketch, and it appears to be genuine. However, I can't test the power-down sleep current until I remove the power indicator LED and the regulator, which I will do at some point.
I don't think so. Pins 3 and 6 in the TQFP package were GND and VCC on the 328P, but are now two of the new GPIO pins. The schematic for the original Pro Mini shows those pins being used for power. But I suppose it's possible the designers of the "The Simple" clone board didn't use them. But otherwise, the board layout would be different.
Edit: I see I just repeated what you said earlier. Anyway, I got out my meter and find that there's no low-impedance connection between pins 3 or 6 of this board and Vcc or GND. But I don't have an old "The Simple" board to see how that was laid out. It may have been the same.
I judge you were intentionally deceived.
Well, as we've now confirmed, the only reason I noticed it wasn't a 328P was because I looked at the marking. Otherwise I would never have known.
A serial port can be a master-mode SPI port so perhaps they make an SPI port / serial port? That feels cheesy so I can whine?
I think just trying to bootload it would reveal the signature. Since the first thing I do with Pro Mini is bootload it as Uno, I would have to load the MiniCore. I just had a look at Aliexpress for a couple hours and came to the conclusion it is unlikely you could get a Pro Mini with ATmega328P any more.
I used Kevin Darrah's counterfeit checker, which also reports the actual signature of the chip, and it is indeed 1E9516, despite the fact that the bootloader on it reports the 328P value instead, which is 1E950F.
// Dump the signature block from an Uno, Nano or Pro Mini
// to help detect counterfeit Atmega328P chips.
// See https://www.youtube.com/watch?v=eeDC1m7ANJI
// for how to interpret the output.
// Thanks to Kevin Darrah for this code and the video.
#include <avr/boot.h>
#define SIGRD 5
void setup() {
Serial.begin(9600);
Serial.println("");
Serial.println("boot sig dump");
int newLineIndex = 0;
for (uint8_t i = 0; i <= 0x1F; i += 1) {
Serial.print(boot_signature_byte_get(i), HEX);
Serial.print("\t");
newLineIndex++;
if (newLineIndex == 8) {
Serial.println("");
newLineIndex = 0;
}
}
Serial.println();
}
void loop() {
}
I think just trying to bootload it would reveal the signature.
The bootloader is supposed to read the signature of the chip and forward it when requested by AVRdude. But what the module makers of the Far East have done is to change the bootloader so it just reports the 328P's signature without bothering to find out what the signature actually is. I had the board setting set to the Pro Mini, 5V 16MHz 328P, and it flashed the Blink example just fine, even though it isn't really a 328P. That would never happen if it was reporting the real signature.
Well, for my project I think I will flash the bootloader that's supposed to be on a PB, and then thereafter call it a PB in the IDE. That will also give me access to the added peripherals.
I just had a look at Aliexpress for a couple hours and came to the conclusion it is unlikely you could get a Pro Mini with ATmega328P any more.
Yes, and that may be the case for Nanos too. Well, as far as I can tell, the only downside of the PB is that it doesn't sleep quite as soundly as the P - something like 3 to 4uA instead of some small fraction of 1uA. A small effect on battery life I guess.
The bootloader is supposed to read the signature of the chip and forward it when requested by AVRdude.
None of the Arduino bootloaders has ever actually read the signature bytes of the chip - they've always been hard coded into the bootloader binary.
I just had a look at Aliexpress for a couple hours and came to the conclusion it is unlikely you could get a Pro Mini with ATmega328P any more.
The real one is still available
Arduino Pro Mini 328 - 5V/16MHz - SparkFun Electronics and Arduino Pro Mini 328 - 3.3V/8MHz - SparkFun Electronics