True Atmega Standalone, Running Without Crystal Oscillator (Arduino): I recently ordered a bunch of Atmel Atmega chips, 328 to be precise and as soon as i got them i realised i was lacking some very important components to make these chips function....
enable verbose logging. If it shows that it's getting signature of 000000 you've set fuses so it needs a crystal, but no crystal is connected, therefore you can't do anything to it over ICSP. Connect a crystal, set the fuses correctly (low fuse should be E2 to use internal), then remove it, or otherwise supply an external clock signal long enough to fix the fuses.
Problem can have several different reasons. There is lots of same or similar problems discussed. First of all is wrong connection or circuit. Check it carefully again.
Was your chip brand new, previously unused and without bootloader? If not then could be a problem with settings for external crystal.
Provide more detailed verbose output from upload (preferences in IDE).
Also a little trick I use sometimes when I'm lazy or the board doesn't cater for an external oscillator is to tap to the clock pin on the programmer itself. If your programmer has an oscillator it likely will be fine for you.
This way you have all you need with just a little wire going from the programmer's oscillator to XTAL1 pin.
I recently had to search about 10 different webpages (counting only the ones I found useful) and piece together what I needed to install the bootloader on an atmega328p-p (the long pins version) WITHOUT a crystal. Because I don't want a crystal and 2 caps in my circuit if I can avoid it.
GO to this folder Arduino15 and open the folder "packages" then open MiniCore (if you used what I used)
then open "hardware" then "avr" then 2.0.3 or whatever until you get to a file called "boards.txt".
Do not do this. If you have to change the f_cpu entry for the 8MHz to 16000000 and get correct timing, it is running at 16MHz. Not 8MHz. 3.3v is out of spec, and power consumption is as for 16MHz, not 8MHz. The only time this could appear to work is if you did NOT do burn bootloader sucessfully with 8MHz external crystal selectected as clock source (to produce initial symptom) nor after making that change.
Connecting ISP programmer and doing burn bootloader (with unmodified version of boards.txt!) should fix problems like this (note that if you're using an external crystal, the frequency will be that of the external crystal, which needs to match what you tell the IDE)
I have a STM32L0x2 (M0+ core) project where, so far, I used to jump from the MCU app to my custom bootloader for updating the app in flash with a new program binary image, by setting flags in the backup registers and doing a SysReset.
But if there was a way to do this and be absolutely sure that the bootloader starts off with a clean system - except the configuration of that one GPIO which needs to remain an output and "HI" for the whole time, that would help with this.
Are you talking about jumping to your own custom bootloader? You can configure that any way you want, certainly if you don't mess with that pin's configuration in your bootloader, it will remain constant. The bootloader is just a program, after all.
We're using the STM32F7 in our project and would like to flash over USB. In the host application we use USB for data transfer which works well. Unfortunately, I have had no success getting the device into the bootloader as we have no access to the boot pins. I tried this code I found on the internet but the the linux dfu-util -l command says no dfu devices found. I noticed this command takes a long time, same with lsusb when the board is in the bootloader (if it even is). Maybe the USB enumeration ist working properly?
Also, I'm not sure what to do with the option bytes. Should I change what happens when the boot0 pin is low so that it runs the bootloader? How will it start my code afterwards?Is this really the recommended way of entering the bootloader from software? It seems rather complicated and not to mention risky as the document said corrupt write can cause device to lock.
I've opted for a separate bootloader now as was in the example and this ( =n_LDXOQHerU&t=570s) video but I can't seem to get it to jump to my application code. Even if I put the above code right after main is called it just seems to hang in TIM1 interrupts (void TIM1_UP_TIM10_IRQHandler(void)). Any idea what could be wrong?
Iam studying the concepts of operating system. The basic starting point of an OS is its Boot loader. Boot loader is most often written in assembly language. Is it possible to create a boot loader without even a single line of assembly language?
However, none of this has anything to do with practicality. For a lot of cases (e.g. 80x86 BIOS) its far easier to use some assembly than to avoid it. Note that "some assembly" may just mean wrappers around firmware's functions and a little initialisation code; where the majority of the boot loader is in some other language.
Technically, it is possible. You need an compiler that can generate specific instructions. You might be able to do it with a C compiler with in-line assembly. The old BLISS programming language might be able to do it in some implementations.
Well, the starting point of an OS is not the bootloader. On some systems (I've done this on an ARM7) you can run your OS without any bootloader. If you don't need any bootloader, you don't need any assembly instruction in your bootloader.
What about the OS itself ? The primary role of an OS is scheduling several tasks, each task having its own context. Most processor architecture rely on a stack to allocate memory for local variables. Languages usually abstract the concept on stack, and only keep the "local variable" concept, and thus are unable to switch the tasks contexts. So, basically, it is not possible to write an OS only in C language. Nevertheless, some languages give access to every processor resources (mostly internal registers). For instance, the PL/M51 allows to write an OS without any assembly for an intel 8051 processor.
If you have Intel BITS, you can write loader in Python.
Otherwise, you can use UEFI libraries to write loader in C or C++.
Instead this ways, you can write a compiler that converts your C++ code into X86 machine code and creates special assembly to boot your kernel. Then you may not write a bootloader.
And, if you do not have BITS or UEFI and you don't want to do this, you can't do this.
However the question in the title differs from the question in the body; a boot-loader is not part of the OS, and an OS that includes pre-emptive scheduling almost certainly needs some assembly language code to at least perform context switches.
I'm working on MCUboot and curious to know what's the main difference between the normal bootloader and bootloader with MCUboot. I have gone through many documents but unfortunately I haven't find any document with explains the difference. Can I get any pictorial representation to identify the bootloader without MCUboot and with MCUboot.
3) Compile the bootloader. -> Should I use "secure_bootloader_uart-mbr_pca10056"? Or "secure-bootloader_usb_mbr_pca10056" ? Debug? no Debug?
I've decided to use: secure_bootloader_uart_mbr_pca10056 no debug. and change the public key with the ones generated from step 1.
Build ran OK.
6. Make sure that the device enters DFU mode. DFU mode is indicated by LED 3 being lit. If a valid application is installed on the device, hold Button 4 during startup to prevent the bootloader from starting the application and force it to enter DFU mode instead.
Then it won't even run the application after power cycle (no LED cycling), and the memory layout got messed up. When seen with nrfConnect I see Softdevice at 0x1000 to 0x1EBF0 and the app at 0x1F000. See below.
More questions:
1) Does this example "Secure DFU Bootloader over Serial Link (UART/USB)" expect us to use the UART or USB example? Or will either one work?
For running either of those 2 examples, do I need to connect the USB cable on 52840 DK Board to the JLINK port, or to the nRF USB port?
2) How many hex files do I need to program for an empty DK eval? I think I need to program:
MBR.Hex (resides at 0x0000)
Application (such as blinky_mbr.hex) starting from 0x1000
output.hex, which consists of Bootloader Settings + Bootloader
Compile the bootloader. -> Should I use "secure_bootloader_uart-mbr_pca10056"? Or "secure-bootloader_usb_mbr_pca10056" ? Debug? no Debug?
I've decided to use: secure_bootloader_uart_mbr_pca10056 no debug. and change the public key with the ones generated from step 1.
Build ran OK.
UART and USB are different transport layers, but this might be confusing in this case. The difference between the two bootloaders are that the USB bootloader does not require a signature for the Application and so on, it only requires for the bootloader. The UART bootloader on the other hand is "secure" and requires a signature for all the components (like the BLE bootloader).
1) Does this example "Secure DFU Bootloader over Serial Link (UART/USB)" expect us to use the UART or USB example? Or will either one work?
For running either of those 2 examples, do I need to connect the USB cable on 52840 DK Board to the JLINK port, or to the nRF USB port?
Andreas,
Thanks for the detailed answer! That's very helpful. I was able to upgrade via UART by replacing step 7 with:
nrfutil dfu serial -pkg my_blinky_mbr.zip -p COM11
About your answer "The difference between the two bootloaders are that the USB bootloader does not require a signature for the Application and so on, it only requires for the bootloader. The UART bootloader on the other hand is "secure" and requires a signature for all the components (like the BLE bootloader)."
Then what is the benefit of using USB? I'm trying to evaluate which one I should implement for our product.
Also, I tried to use the USB example by doing the previous steps, but replacing the following: