Remove Bootloader on Arduinos - c

I am trying to move from arduinos to AVR C. Would somebody know how to remove the arduino bootloader from the microcontroller? Is there a different process for the different atmega microcontrollers like the 32u4, 328, or 2560?
Thanks.

The Arduino bootloader will be removed when you program the atmega using a programmer.
When you program Arduino using the Arduino bootloader it knows how to write to the image such that the bootloader is preserved.
When you create an image from AVR C and flash it to the atmega the image will overwrite the bootloader, when your atmega is next reset it will now run your image instead of the bootloader.
The process will be the same regardless of the part however your project will need to be set up appropriately.

You can use AVR dude to erase the flash. This thread might help
http://www.avrfreaks.net/forum/how-can-i-erase-chip-using-avrdude

Related

niosii processor Altera C program

I'm currently working on the Altera DE0 board with the QuartusII Web Edition software. I need to use a nios processor on Qsys to display a shifted signal from a GPIO pin on my board. The input signal would be a clock signal from an external source. The problem is that I have no idea how I can write a program in C (on the Eclipse IDE) for diplaying a delayed clock on an oscilloscope.
My Qsys design looks like that Image1 => Qsys Design and here the Eclipse IDE where I have to write my C program Image2 => Eclipse IDE
Please help me !
thank you very much in advance for the replies
start with the system.h file to know which base_address is assigned to each peripherial, then you can use pointers to directly access the GPIO or use the IORD/IOWR functions.

How Does STM32 Factory Bootloader Allow for Reflashing at any Time?

I'm aware that on some STM32 boards, they come with a built in bootloader in their ROM. Quoting from STM32 Application Note
The bootloader is stored in the internal boot ROM (system memory) of STM32 devices, and is
programmed by ST during production. Its main task is to download the application program to the
internal Flash memory through one of the available serial peripherals (such as USART, CAN,
USB, I2C, SPI).
However the ability to reflash at any time, i.e. trigger a reflash when your board is a running a program confuses me. My understanding is that a bootloader is the first piece of code to execute and then launches your user program. However, to facilitate this flashing at any time, won't the bootloader have to constantly poll for a request to reflash?
The bootloader only polls for an update on start-up/reset. So not "anytime" in the sense of "spontaneously" - you do have to trigger it. If the programmer has access to the reset pin or control of power, it can of course invoke a restart.
Moreover the ROM bootloader only runs at all if the BOOT pins are set appropriatlely. The boot modes are Flash, SRAM or ROM.
Your understanding is right. Almost.
In case of STM32, you need to set up the chip to run the bootloader, typically using BOOT pins. When the bootloader runs, it checks if the programming is necessary by monitoring the specific peripherals. If the programming is not triggered, it jumps to the user program.
Therefore, you cannot reprogram at any time, only at boot time.
Here is an example bootloader flowchart for programming over UART or I2C.
See this application note on STM32 bootloader for more details.

Programming external QSPI flash Raspberry Pi Pico

I want to reprogram the external flash of a raspberry Pico via SWD line.
This feature must be implemented in a different microcontroller, not from a Linux computer so the OpenOCD library cannot be used.
I already wrote a C library that is able to read and write in RAM and in core registers via SWD and I'm able to put the Cortex-M0+ into halt state.
I read many tutorials and documentation and those that are useful are:
http://markding.github.io/swd_programing_sram/
https://www.silabs.com/documents/public/application-notes/an0062.pdf
https://community.silabs.com/s/article/how-to-program-internal-sram-over-swd?language=en_US
but unfortunately they aren't clear enough.
Can you explain the sequence of commands that I should send to RP2040 to correctly upload the new firmware?
Thanks for your help!

STM32 F407VG Boot into different (main-)applications

For a project I just started working on, I need to write a firmware in C that lets me boot into two different firmware versions. The task is to be able to update a device which includes an STM in the field using the RS485 Port with an Intel .hex file. My idea was to place the two firmware versions at designated starting addresses in the flash, including some kind of checksum for data integrity. According to the flash module organization found in the reference manual, my first thought was to place one version into sector 10 (starting at 0x080C0000) and the other version into sector 11 (starting at 0x080E0000). After every reset, the STM32 should boot into a "bootmanager" which is just minimum code that decides, whether the firmware in sector 10 or sector 11 is the newer version. I want to clarify my idea in the following graphic:
[Rough process][1]
[1]: https://i.stack.imgur.com/xLowh.png
The 128kBytes of every sector are sufficient. So far, I was able to write Single Bytes into the Flash and read them afterwards. Also, I have already set up a working UART communication using the RS485.
My questions
Can I just write the .hex file into the Flash as it is without modification like
:020000040800F2
:1000000002200B
etc?
As I am unexperienced with with jumps: How should I perform the jump from the "bootmanager" into sector 5 firmware? Are the adresses automatically relative to the entry point in sector 5?
Can you give me keywords or tell me, what challenges I will encounter?
*EDIT: I'm aware that the STM itself contains a bootloader. Unluckily, the RS485 device is hardwired to the GPIO pins used by USART2. According to the reference manual, the internal bootloader can only be used by USART1 and USART3, CAN2 and USB OTG FS
Can I just write the .hex file into the Flash as it is without
modification like
no you cant. You need to modify the linker script to archive it
You need to have the whole both applications in the FLASH so divide it 50/50%.
I usually add some serial FLASH to have a copy of the firmware if both of the images are damaged.
Yuo need to write the custom bootloader.
Most of the STM32 microcontrollers have support for dual memory bank and on the fly update (cf AN4767 - On-the-fly firmware update for dual bank STM32 microcontrollers)
This will allow to perform exactly what you require.
Usually the microcontroller will need to have a bootloader and 2 banks for the image.
When booting the bootloader will start and check which version it would have to boot and set the start address accordinngly.
This application note is for the F7 series but you can check it to see how it could work for your specific microcontroller (cf AN4826 - STM32F7 Series Flash memory dual bank mode).
Regarding your questions:
The code would be written as usual but twice (or 2 different firmwares)
Look into the application notes referenced and keywords such as: dual bank, on-the-fly update, DFU, etc

Is it possible to write Cert.der and key.der in internal flash EEprom at run time? I am using stm32

All I am trying to write certifictae and key to flash EEPROM of stm32 , I know we can write the string but is it possible to write whole certificate(.der) in flash. I am using stm32f7 microcontroller and using internal eeprom. and I want to add certificate and key at run time. I can write a simple Json object to the node and it works fine but i have no idea if i can write a cert.der/key.der in the Mcu.
ST offer an HAL library for manage the R/W on EEPROM. If you want to use this tool, you can found all details on project link X-CUBE-EEPROM and EEPROM emulation techniques and software for STM32L4 and STM32L4+ Series microcontrollers.
If you prefer to write yourself the R/W functions, you can found a good start point at ST community forum: EEPROM read/write.
A little note: when you try to find some reference about STM32 EEPROM
inside MCU package, many, many, many time you can found for STM32L*
family. Don't worry, the porting to another MCU is very easy.

Resources