so i started working with AVR assembly and it's interesting .. you have those .CSEG , .DSEG and .ESEG to getermine where that part of the code will be programmed and then it will all be somehow be placed in an hexadecimal file .
anyway all i am interested in in this post is the .CSEG the data that will be placed in the code segment which is the flash memory . now l'ets say i do not have any constants or arrays to be placed the code segment all i want is a number of assembler commands with argumants (brute assembly code) .
now i do not want that to be compiled into a full assembly file . i want it to be assembled into the exact same stuff that will be placed in the program memory .
so that if i happen to write that data starting from an address in program memory, it needs to be executed after i make a jump to it from the program .
i did try this the conventional way , but HEX files seem to have an other order and different other elements placed into them .
I can't quite figure out what it is you are trying to do. You can use avrdude to load data into the FLASH memory of you avr chip. The Arduino IDE uses Intel Hex format files but avrdude can understand some other data formats, perhaps even raw binary files. Read the avrdude documentation.
If you use an ISP device (USBasp, USBtiny, etc) you can use avrdude to write all of FLASH memory. If you use the Arduino bootloader you can use avrdude to write to the application segment of FLASH (the part not set aside for the bootloader).
johnwasser:
I can't quite figure out what it is you are trying to do. You can use avrdude to load data into the FLASH memory of you avr chip. The Arduino IDE uses Intel Hex format files but avrdude can understand some other data formats, perhaps even raw binary files. Read the avrdude documentation.
If you use an ISP device (USBasp, USBtiny, etc) you can use avrdude to write all of FLASH memory. If you use the Arduino bootloader you can use avrdude to write to the application segment of FLASH (the part not set aside for the bootloader).
thank you very much john ... the programming part is not the problem . i am working on loading the program code to a specific section of the program memory in the bootloader . that's why i want the code as it is , my program already knows the placement address of the program in program memory so all i need in the SD card is the program words as they are (the way they will be placed in program memory) .
The Intel Hex Format includes target memory location, so you could just create the HEX with the memory addresses you want and use that, no? Not quite grasping exactly what you are trying to do here or why.
I think the answer to your question is to convert your object file using avr-objdump. Like:
avr-objdump –O binary yourfile.o yourfile.bin
But do you understand you're trying to open a can of worms? Have you considered, the vector table, program reset, the stack, initialized variables, program address relocation…
JimEli:
I think the answer to your question is to convert your object file using avr-objdump. Like:
avr-objdump –O binary yourfile.o yourfile.bin
But do you understand you're trying to open a can of worms? Have you considered, the vector table, program reset, the stack, initialized variables, program address relocation…
i actually did consider those elements . what i am planning to do is to have the bootloader installed in that 2kw space , then have a second program compiled for it to be placed at a late place in program memory .
the addresses 0x0000 -> the limits of the second program before the bootloader should be reserved
so the program address relocation should not be a problem since i will be placing the program in its main position . at the end , the bootloader does not call the address 0x0000 it calls the first address of the secondary program .
the problem now is the other parts you mentioned , "initialized variables" and "the stack" .... etc
i think those elements can also be taken care of . even though after a chip reset i do not understand why that should matter .
amine2:
my program already knows the placement address of the program in program memory so all i need in the SD card is the program words as they are
This is the first time you have mentioned an SD card. What is it you are trying to do with data on the SD card? Load it as a sketch? I know that there is at least one existing SD bootloader that does that. I think it uses the same Intel Hex format as avrdude.
johnwasser:
This is the first time you have mentioned an SD card. What is it you are trying to do with data on the SD card? Load it as a sketch? I know that there is at least one existing SD bootloader that does that. I think it uses the same Intel Hex format as avrdude.
i know .. i think it's called 2Boots or something like that , it's the same principle but my code is more specific than that
Um. .CSEG and related are commands for the Atmel Assembler, which is not normally part of the Arduino distribution (which has the Gnu assembler instead, and it's different.) To put code at an absolute location with the Atmel assembler, you would probably use ".ORG" without any of the segment directives (CSEG is the default), but to be sure, something like:
.CSEG
.ORG 0x7000
bootstart: ;; start of bootloader code
:
With the gnu assembler, you'd leave out assembler directives, and use linker commands or map files to position the normal ".text" segment wherever you wanted it to go. (you COULD add additional "segments" to the source code, but there's not much reason to do so unless you'll be linking with other code.)