CLawson's SD bootloader implementation on bigger AVR

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everybody,

I was looking for a SD bootloader and finally I decided to adapt Cliff’s code to my ATmega1284.

I have already searched for any similar post with Cliff’s sd bootloader which implemented to a bigger ATmega, but I didn’t find something.

So, I did some changes and finally I succeeded to compile the bootloader code without errors.

I would like to show you the changes that I have done…

 

*bootloader part*

  • In defined symbols (-D) field
  1. I changed the bootloader start address to BOOT_ADR=0x1E000 (in bytes).
  2. I changed the F_CPU=20000000

 

  • In FLASH segment field
  1. I changed the start bootloader address to .text=0xF000

 

  • In the AVR/GNU Assembler \ General
  1. I changed the assembler flags to –DF_CPU=20000000

 

  • In the asmfunc.S
  1. I replaced all SPMCR registers with SPMCSR
  2. Because I’m using the PA0 as a SD CS pin I wrote these two lines of code in configure.h
#define SD_CS_PORT PORTA
#define SD_CS_DDR  DDRA

and then I did these changes here

#define	DDR_CS	_SFR_IO_ADDR(SD_CS_DDR), CS_PIN   //MMC CS pin (DDR, PORT)
#define	PORT_CS _SFR_IO_ADDR(SD_CS_PORT), CS_PIN
  • In the uart.c

I changed all registers concerning the uart to uart0 since my MC has two uarts.

 

I’m using AS7 and my application code added to the bootloader solution. Like the avrapp in Cliff’s solution.

 

*Now, in the app part.*

In built events tab I wrote the same command with the address correction according to ATmega1284 application size.

 

..\..\srec_cat $(MSBuildProjectDirectory)\$(Configuration)\$(Output File Name).hex -intel -fill 0xFF 0x0000 0xEFFE --l-e-crc16 0xEFFE -o AVRAP001.bin –binary

 

The only changes in this command were the address correction for CRC storage and the .bin file name foo to AVRAP001.

When I tried to build the application project this error pop up.

 

The command "..\..\srec_cat C:\Users\SpaceMan\Desktop\projV3boot\avrapp\Debug\.hex -intel -fill 0xFF 0x0000 0xEFFE --l-e-crc16 0xEFFE -o AVRAP001.bin -binary" exited with code 1.

 I have installed the winAVR and I have a copy of the srec_cat.exe in the path of bootloader project.

 

* This is the build output.*

------ Build started: Project: avrapp, Configuration: Debug AVR ------
Build started.
Project "avrapp.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\SpaceMan\Desktop\projV3boot\avrapp\avrapp.cproj" (target "Build" depends on it):
	Task "RunCompilerTask"
		Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
		C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 4 --output-sync
		make: Nothing to be done for 'all'.
	Done executing task "RunCompilerTask".
	Task "RunOutputFileVerifyTask"
				Program Memory Usage 	:	50148 bytes   38,3 % Full
				Data Memory Usage 		:	3533 bytes   21,6 % Full
	Done executing task "RunOutputFileVerifyTask".
Done building target "CoreBuild" in project "avrapp.cproj".
Target "PostBuildEvent" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets" from project "C:\Users\SpaceMan\Desktop\projV3boot\avrapp\avrapp.cproj" (target "Build" depends on it):
	Task "Exec"
		..\..\srec_cat C:\Users\SpaceMan\Desktop\projV3boot\avrapp\Debug\.hex -intel -fill 0xFF 0x0000 0xEFFE --l-e-crc16 0xEFFE -o AVRAP001.bin -binary
		srec_cat: C:\Users\SpaceMan\Desktop\projV3boot\avrapp\Debug\.hex: open: No such
		    file or directory
C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets(36,5): error: MSB3073: The command "..\..\srec_cat C:\Users\SpaceMan\Desktop\projV3boot\avrapp\Debug\.hex -intel -fill 0xFF 0x0000 0xEFFE --l-e-crc16 0xEFFE -o AVRAP001.bin -binary" exited with code 1.
	Done executing task "Exec" -- FAILED.
Done building target "PostBuildEvent" in project "avrapp.cproj" -- FAILED.
Done building project "avrapp.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

 

Can someone help me and explain what does it means the command exited with code 1?

For sure I missed something and especially with the srec_cat procedure.

Thanks in advance.

Last Edited: Tue. Feb 13, 2018 - 09:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kobogia wrote:
Can someone help me and explain what does it means the command exited with code 1?

Well the thing it's complaining about is:

..\..\srec_cat C:\Users\SpaceMan\Desktop\projV3boot\avrapp\Debug\.hex -intel -fill 0xFF 0x0000 0xEFFE --l-e-crc16 0xEFFE -o AVRAP001.bin -binary

Just ".hex" is not a valid filename. Presumably that should really have been something like avrapp.hex ?

 

If you disable the CRC support then you don't need this srec_cat step anyway. Just do an avr-obcopy to convert avrapp.hex to avrapp.bin or even change the original avr-objcopy command so it uses "-O binary" instead of "-O ihex"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Mr. Lawson,

I understood how it works and finally I succeeded to create the *.bin file.

Of course the bootloader doesn't work...! :-)

The “diagnostic” LED is always ON and there is no uart activity.

 

clawson wrote:
If you disable the CRC support then you don't need this srec_cat step anyway.

 

Does it means we use the .hex file instead of *.bin in SD?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Does it means we use the .hex file instead of *.bin in SD?

No to put an Intel Hex decoder into the bootloader itself would bloat it way beyond my 1..2K design goal. Anyway there are far too many subtleties to iHex (like the lines don't even have to be in address order!) to be able to cope with all that in AVR code. Tools liike avr-objcopy and srec_cat do a far better job of handling iHex than an AVR can. So the file on the card always has to be .bin

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
the lines don't even have to be in address order

lots of people fail to realise this and end up in a Big Mess!!