Go Down

Topic: Flashing a sketch from SD card using 2boot bootloader (Read 32244 times) previous topic - next topic

ysinotelodigo

...

After a long time and many tries, I find the right flow to be able to burn the new boot loader on an atmega328p dip28 and load the blink example project into the avr from a 512Mo SD card:

- get the github from
https://github.com/willie68/OpenSeaMapLogger/tree/master/bootloader/avr_boot-master

- check your hardware SD <-> Arduino with avr_boot-master/asmfunc.S

- make

- burn fuse
avrdude -p atmega328p -c usbasp -P usb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m

- burn boot loader
avrdude -p atmega328p -c usbasp -P usb -U flash:w:avr_boot-master/avr_boot.hex:i -Ulock:w:0x0F:m

- compile blink project

- find the compiled file
find $TMPDIR -name Blink.cpp.elf

- convert hex to binary
avr-objcopy -O binary Blink.cpp.elf OSMFIRMW.BIN

- plug the SD card and wait the reboot (it may take long time)


Hello,

I would like to be able to load the blink example from microSD card.

I have an Arduino Uno. I downloaded avr_boot.hex from repository and added a configuration in the board.txt file with a program called "board.txt Editor".

My configuration is:
uno___2.name=Arduino SD
uno___2.build.mcu=atmega328p
uno___2.build.f_cpu=16000000L
uno___2.build.core=arduino
uno___2.build.variant=standard
uno___2.upload.protocol=arduino
uno___2.upload.maximum_size=32256
uno___2.upload.speed=115200
uno___2.bootloader.low_fuses=0xff
uno___2.bootloader.high_fuses=0xd8
uno___2.bootloader.extended_fuses=0x05
uno___2.bootloader.path=bootsd
uno___2.bootloader.file=avr_boot.hex
uno___2.bootloader.unlock_bits=0x3F
uno___2.bootloader.lock_bits=0x0F

I have a 2 GB microSD with FAT16 and Ethernet-SD board. I generated blink.cpp.elf in Windows, generated the OSMFIRMW.BIN with avr-objcopy command and added the OSMFIRMW.BIN file in root folder.

I couldn't load the blink example from microSD. Do I need to buy a SD card? What thing did I do wrong?

Thank you

Ghostwheel

Howdy,

 First off, thank you for the effort you've put into this.  I'm following your instructions, and I want to check my work before I get too far along.

When I get to step 3, make, I get this error:

Code: [Select]
$ make
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega328p -DBOOT_ADR=0x7000 -DF_CPU=16000000   -c -o main.o main.c
main.c:58:19: warning: 'mem_cmpP' declared 'static' but never defined [-Wunused-function]
 static inline int mem_cmpP(const void* dst, const void* src, int cnt);
                   ^
main.c:65:16: warning: 'pagecmp' defined but not used [-Wunused-function]
 static uint8_t pagecmp(uint16_t addr, uint8_t *data)
                ^
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega328p -DBOOT_ADR=0x7000 -DF_CPU=16000000   -c -o pff.o pff.c
pff.c: In function 'get_fat':
pff.c:384:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   return LD_WORD(buf);
   ^
pff.c:388:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   return LD_DWORD(buf) & 0x0FFFFFFF;
   ^
pff.c: In function 'pf_mount':
pff.c:757:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     bsect = LD_DWORD(&buf[8]); /* Partition offset in LBA */
     ^
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega328p -DBOOT_ADR=0x7000 -DF_CPU=16000000   -c -o mmc.o mmc.c
avr-gcc -c -mmcu=atmega328p -I. -x assembler-with-cpp -Wa,-adhlns=asmfunc.lst,-gstabs -DBOOT_ADR=0x7000 -DF_CPU=16000000 asmfunc.S -o asmfunc.o
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega328p -DBOOT_ADR=0x7000 -DF_CPU=16000000 -Wl,-Map,avr_boot.map -Wl,--section-start,.text=0x7000 -o avr_boot.elf main.o pff.o mmc.o asmfunc.o
avr-objdump -h -S avr_boot.elf > avr_boot.lst
avr-objcopy -j .text -j .data -j .fuse -O ihex avr_boot.elf avr_boot.hex
avr-size -C --mcu=atmega328p avr_boot.elf
avr-size: invalid option -- C
Usage: avr-size [option(s)] [file(s)]
 Displays the sizes of sections inside binary files
 If no input file(s) are specified, a.out is assumed
 The options are:
  -A|-B     --format={sysv|berkeley}  Select output style (default is berkeley)
  -o|-d|-x  --radix={8|10|16}         Display numbers in octal, decimal or hex
  -t        --totals                  Display the total sizes (Berkeley only)
            --common                  Display total size for *COM* syms
            --target=<bfdname>        Set the binary file format
            @<file>                   Read options from <file>
  -h        --help                    Display this information
  -v        --version                 Display the program's version

avr-size: supported targets: elf32-avr elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex
make: *** [size] Error 1


Seems to compile, but I don't know how critical the avr-size output is, and if this error keeps any further steps from occurring.  Running it by hand looks like this:

Code: [Select]
$ avr-size avr_boot.elf
   text   data    bss    dec    hex filename
   3932     26    173   4131   1023 avr_boot.elf


There is a avr_boot.hex, but at 11,174 bytes, it seems too big to me.

Am I on track here, or did I hose something?

-Chris


Hi all,

just a short message to thanks everybody that contribute to release avr_boot.

After a long time and many tries, I find the right flow to be able to burn the new boot loader on an atmega328p dip28 and load the blink example project into the avr from a 512Mo SD card:

- get the github from
https://github.com/willie68/OpenSeaMapLogger/tree/master/bootloader/avr_boot-master

- check your hardware SD <-> Arduino with avr_boot-master/asmfunc.S

- make

- burn fuse
avrdude -p atmega328p -c usbasp -P usb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m

- burn boot loader
avrdude -p atmega328p -c usbasp -P usb -U flash:w:avr_boot-master/avr_boot.hex:i -Ulock:w:0x0F:m

- compile blink project

- find the compiled file
find $TMPDIR -name Blink.cpp.elf

- convert hex to binary
avr-objcopy -O binary Blink.cpp.elf OSMFIRMW.BIN

- plug the SD card and wait the reboot (it may take long time)



john1993

I think, it was stalled, but then i found this.
The thread owner has found a way to make it work.
http://harizanov.com/2013/01/2boots-bootloader-on-the-uiot-serial-mmc-bootloader-in-2kb/
His changes are on his own github repository...
that is exactly what myself and many others here would find useful but unfortunately his only compiled version was for a rather queer 6mhz clock (what goes through these guys heads?). most need something for 16mhz uno/promini. i tried:

https://github.com/thseiler/embedded/blob/master/avr/2boots/build/2boots-arduino-atmega328p-16000000L-PD4.hex

maybe that is one of the earlier non-functional versions. using 1gb fat16 sd with "BLINK3.HEX" file and running NameBoardSketch.pde altered for "BLINK3" but the sketch dont load. has anybody ever got this to run on a regular m328 ardunio?

it is surprising such a highly prized capability as loading from sd is not part of mainstream arduino.


Go Up