From: Brandon F. <BFo...@mo...> - 2010-02-10 17:11:22
|
I'm working on a bootloader for an 8051-based project (Nordic nRF24Le1), and I need to make linker scripts to put everything in its proper place. But I can't seem to find any example linker scripts, or even the default scripts used by SDCC. Can someone point me in the right direction? |
From: Jan W. <we...@ef...> - 2010-02-10 20:13:51
|
Well, I am not the most qualified to answer, but SDCC's linker is not scriptable as you might been used to. For code/data segments [re]location you might want to look at the hints in http://sdcc.sourceforge.net/doc/sdccman.html/node48.html . Jan Waclawek >I'm working on a bootloader for an 8051-based project (Nordic nRF24Le1), an= >d I need to make linker scripts to put everything in its proper place. But = >I can't seem to find any example linker scripts, or even the default script= >s used by SDCC. Can someone point me in the right direction? |
From: Brandon F. <BFo...@mo...> - 2010-02-11 08:50:37
|
That's disappointing. Is there another linker that I could use instead? I had found that page, but it seems that I can only relocate the entire code segment along with the interrupt vectors. I need to relocate the code, but not the vectors. Has there been any effort towards creating a new linker? Should I write one? -----Original Message----- From: Jan Waclawek [mailto:we...@ef...] Sent: Wednesday, February 10, 2010 9:14 PM To: sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? Well, I am not the most qualified to answer, but SDCC's linker is not scriptable as you might been used to. For code/data segments [re]location you might want to look at the hints in http://sdcc.sourceforge.net/doc/sdccman.html/node48.html . Jan Waclawek >I'm working on a bootloader for an 8051-based project (Nordic >nRF24Le1), an= d I need to make linker scripts to put everything in its >proper place. But = I can't seem to find any example linker scripts, or >even the default script= s used by SDCC. Can someone point me in the right direction? ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Maarten B. <sou...@ds...> - 2010-02-11 09:29:57
|
Brendan, SDCC does not accept a linker script, but it creates one (extension .lnk) when calling the linker. You can adapt it (or write it yourself) and then call the linker manually instead of through SDCC. Use sdcc -V --verbose to see how the linker is called. To relocate only the code and not the vectors, you could use a .asm file with the vectors in an ABS area with .org 0x0000. You could also try to use -Wl-bCSEG=0x1000 and the like. Maarten > That's disappointing. Is there another linker that I could use instead? > > I had found that page, but it seems that I can only relocate the entire > code segment along with the interrupt vectors. I need to relocate the > code, but not the vectors. > > Has there been any effort towards creating a new linker? Should I write > one? > > -----Original Message----- > From: Jan Waclawek [mailto:we...@ef...] > Sent: Wednesday, February 10, 2010 9:14 PM > To: sdc...@li... > Subject: Re: [Sdcc-user] Default linker script for mcs51? > > Well, I am not the most qualified to answer, but SDCC's linker is not > scriptable as you might been used to. > > For code/data segments [re]location you might want to look at the hints in > http://sdcc.sourceforge.net/doc/sdccman.html/node48.html . > > Jan Waclawek > > >>I'm working on a bootloader for an 8051-based project (Nordic >>nRF24Le1), an= d I need to make linker scripts to put everything in its >>proper place. But = I can't seem to find any example linker scripts, or >>even the default script= s used by SDCC. Can someone point me in the >> right direction? > > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > |
From: Brandon F. <BFo...@mo...> - 2010-02-11 10:46:04
|
Both options seem to work. Thank you. For the sake of posterity, the .lnk file can be modified such that the HOME segment points to the desired location for the vectors and the CSEG segment points to the desired code location. Passing -Wl-bCSEG=0x1000 to SDCC on the command line also works. Thanks -----Original Message----- From: Maarten Brock [mailto:sou...@ds...] Sent: Thursday, February 11, 2010 10:30 AM To: sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? Brendan, SDCC does not accept a linker script, but it creates one (extension .lnk) when calling the linker. You can adapt it (or write it yourself) and then call the linker manually instead of through SDCC. Use sdcc -V --verbose to see how the linker is called. To relocate only the code and not the vectors, you could use a .asm file with the vectors in an ABS area with .org 0x0000. You could also try to use -Wl-bCSEG=0x1000 and the like. Maarten > That's disappointing. Is there another linker that I could use instead? > > I had found that page, but it seems that I can only relocate the > entire code segment along with the interrupt vectors. I need to > relocate the code, but not the vectors. > > Has there been any effort towards creating a new linker? Should I > write one? > > -----Original Message----- > From: Jan Waclawek [mailto:we...@ef...] > Sent: Wednesday, February 10, 2010 9:14 PM > To: sdc...@li... > Subject: Re: [Sdcc-user] Default linker script for mcs51? > > Well, I am not the most qualified to answer, but SDCC's linker is not > scriptable as you might been used to. > > For code/data segments [re]location you might want to look at the > hints in http://sdcc.sourceforge.net/doc/sdccman.html/node48.html . > > Jan Waclawek > > >>I'm working on a bootloader for an 8051-based project (Nordic >>nRF24Le1), an= d I need to make linker scripts to put everything in >>its proper place. But = I can't seem to find any example linker >>scripts, or even the default script= s used by SDCC. Can someone point >>me in the right direction? > > > ---------------------------------------------------------------------- > -------- SOLARIS 10 is the OS for Data Centers - provides features > such as DTrace, Predictive Self Healing and Award Winning ZFS. Get > Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ---------------------------------------------------------------------- > -------- SOLARIS 10 is the OS for Data Centers - provides features > such as DTrace, Predictive Self Healing and Award Winning ZFS. Get > Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Brandon F. <BFo...@mo...> - 2010-02-11 11:31:29
|
Well, it looks like I spoke too soon. SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. -----Original Message----- From: Brandon Fosdick [mailto:BFo...@mo...] Sent: Thursday, February 11, 2010 11:42 AM To: sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? Both options seem to work. Thank you. For the sake of posterity, the .lnk file can be modified such that the HOME segment points to the desired location for the vectors and the CSEG segment points to the desired code location. Passing -Wl-bCSEG=0x1000 to SDCC on the command line also works. Thanks -----Original Message----- From: Maarten Brock [mailto:sou...@ds...] Sent: Thursday, February 11, 2010 10:30 AM To: sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? Brendan, SDCC does not accept a linker script, but it creates one (extension .lnk) when calling the linker. You can adapt it (or write it yourself) and then call the linker manually instead of through SDCC. Use sdcc -V --verbose to see how the linker is called. To relocate only the code and not the vectors, you could use a .asm file with the vectors in an ABS area with .org 0x0000. You could also try to use -Wl-bCSEG=0x1000 and the like. Maarten > That's disappointing. Is there another linker that I could use instead? > > I had found that page, but it seems that I can only relocate the > entire code segment along with the interrupt vectors. I need to > relocate the code, but not the vectors. > > Has there been any effort towards creating a new linker? Should I > write one? > > -----Original Message----- > From: Jan Waclawek [mailto:we...@ef...] > Sent: Wednesday, February 10, 2010 9:14 PM > To: sdc...@li... > Subject: Re: [Sdcc-user] Default linker script for mcs51? > > Well, I am not the most qualified to answer, but SDCC's linker is not > scriptable as you might been used to. > > For code/data segments [re]location you might want to look at the > hints in http://sdcc.sourceforge.net/doc/sdccman.html/node48.html . > > Jan Waclawek > > >>I'm working on a bootloader for an 8051-based project (Nordic >>nRF24Le1), an= d I need to make linker scripts to put everything in >>its proper place. But = I can't seem to find any example linker >>scripts, or even the default script= s used by SDCC. Can someone point >>me in the right direction? > > > ---------------------------------------------------------------------- > -------- SOLARIS 10 is the OS for Data Centers - provides features > such as DTrace, Predictive Self Healing and Award Winning ZFS. Get > Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ---------------------------------------------------------------------- > -------- SOLARIS 10 is the OS for Data Centers - provides features > such as DTrace, Predictive Self Healing and Award Winning ZFS. Get > Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Peter V. E. <va...@sf...> - 2010-02-11 19:04:25
|
On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: > Well, it looks like I spoke too soon. > > SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. It is defined in main (and thus will be in the code generator somewhere I expect), and called from sdcc/device/lib/mcs51/crtstart.asm. I expect you would meed to modify the code generator to do what you want (or modify main.asm by hand). vi main.asm ... ; global & static initialisations ;-------------------------------------------------------- .area HOME (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area GSINIT (CODE) .globl __sdcc_gsinit_startup .globl __sdcc_program_startup .globl __start__stack .globl __mcs51_genXINIT .globl __mcs51_genXRAMCLEAR .globl __mcs51_genRAMCLEAR .area GSFINAL (CODE) ljmp __sdcc_program_startup ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area HOME (CODE) .area HOME (CODE) __sdcc_program_startup: lcall _main ; return from main will lock up sjmp . ;-------------------------------------------------------- ... Peter Van Epp |
From: Brandon F. <BFo...@mo...> - 2010-02-11 19:23:08
|
On Feb 11, 2010, at 20:04 , Peter Van Epp wrote: > On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: >> Well, it looks like I spoke too soon. >> >> SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. > > It is defined in main (and thus will be in the code generator somewhere > I expect), and called from sdcc/device/lib/mcs51/crtstart.asm. I expect you > would meed to modify the code generator to do what you want (or modify > main.asm by hand). I was afraid of that. I may take a stab at modifying the generator, just for fun. Does anyone have a git mirror of the repository? |
From: Peter V. E. <va...@sf...> - 2010-02-11 19:56:30
|
On Thu, Feb 11, 2010 at 08:22:57PM +0100, Brandon Fosdick wrote: > > On Feb 11, 2010, at 20:04 , Peter Van Epp wrote: > > > On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: > >> Well, it looks like I spoke too soon. > >> > >> SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. > > > > It is defined in main (and thus will be in the code generator somewhere > > I expect), and called from sdcc/device/lib/mcs51/crtstart.asm. I expect you > > would meed to modify the code generator to do what you want (or modify > > main.asm by hand). > > > I was afraid of that. I may take a stab at modifying the generator, just for fun. Does anyone have a git mirror of the repository? > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user I'm not sure what a git mirror is, but source snapshots are available on the web site, thats where I was looking at the startup code from. Also note I'm far from an expert and may be stearing you wrong :-). Peter Van Epp |
From: Maarten B. <sou...@ds...> - 2010-02-11 21:39:27
|
Brandon, You could also rename your main() to mymain() and generate the necessary startup code yourself in assembly. (Sorry for misspelling your name earlier.) Maarten > > On Feb 11, 2010, at 20:04 , Peter Van Epp wrote: > > > On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: > >> Well, it looks like I spoke too soon. > >> > >> SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. > > > > It is defined in main (and thus will be in the code generator somewhere > > I expect), and called from sdcc/device/lib/mcs51/crtstart.asm. I expect you > > would meed to modify the code generator to do what you want (or modify > > main.asm by hand). > > > I was afraid of that. I may take a stab at modifying the generator, just for fun. Does anyone have a git mirror of the repository? > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > |
From: Brandon F. <BFo...@mo...> - 2010-02-12 16:11:31
|
Ok, that got me a little further. I renamed main() to bootloader() and made a linker script that moves both HOME and CSEG. Then I made my own crtstart.asm that puts " ljmp __sdcc_gsinit_startup" at the reset vector, and changes __sdcc_gsinit_startup to jump to _bootloader instead of __sdcc_program_startup. Compiling and linking all of that gives me output that seems to do what I want. However, I noticed that main.asm has what appears to be code for initializing global variables. And it seems that normally this code is run after a jump to __sdcc_init_data and then there's a jump to __sdcc_program_startup after the initialization is finished. When I changed main() to bootloader() that last jump to __sdcc_program_startup went away. I'm trying to figure out how to get that initialization code to run. I can't jump to __sdcc_init_data because there's no jump after the initialization that will get me back to _bootloader. Any suggestions? (No worries, happens all the time) -----Original Message----- From: Maarten Brock [mailto:sou...@ds...] Sent: Thursday, February 11, 2010 10:39 PM To: sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? Brandon, You could also rename your main() to mymain() and generate the necessary startup code yourself in assembly. (Sorry for misspelling your name earlier.) Maarten > > On Feb 11, 2010, at 20:04 , Peter Van Epp wrote: > > > On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: > >> Well, it looks like I spoke too soon. > >> > >> SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. > > > > It is defined in main (and thus will be in the code generator > > somewhere I expect), and called from > > sdcc/device/lib/mcs51/crtstart.asm. I expect you would meed to > > modify the code generator to do what you want (or modify main.asm by hand). > > > I was afraid of that. I may take a stab at modifying the generator, just for fun. Does anyone have a git mirror of the repository? > ---------------------------------------------------------------------- > -------- SOLARIS 10 is the OS for Data Centers - provides features > such as DTrace, Predictive Self Healing and Award Winning ZFS. Get > Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Brandon F. <BFo...@mo...> - 2010-02-15 09:52:22
|
I think I figured it out. In addition to everything from my last message, I added a GSFINAL section to crtstart.asm with an "ljmp _bootloader" instruction. That seems to have put everything in the right place. Thanks for the help -----Original Message----- From: Brandon Fosdick [mailto:BFo...@mo...] Sent: Friday, February 12, 2010 4:53 PM To: sou...@ds...; sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? Ok, that got me a little further. I renamed main() to bootloader() and made a linker script that moves both HOME and CSEG. Then I made my own crtstart.asm that puts " ljmp __sdcc_gsinit_startup" at the reset vector, and changes __sdcc_gsinit_startup to jump to _bootloader instead of __sdcc_program_startup. Compiling and linking all of that gives me output that seems to do what I want. However, I noticed that main.asm has what appears to be code for initializing global variables. And it seems that normally this code is run after a jump to __sdcc_init_data and then there's a jump to __sdcc_program_startup after the initialization is finished. When I changed main() to bootloader() that last jump to __sdcc_program_startup went away. I'm trying to figure out how to get that initialization code to run. I can't jump to __sdcc_init_data because there's no jump after the initialization that will get me back to _bootloader. Any suggestions? (No worries, happens all the time) -----Original Message----- From: Maarten Brock [mailto:sou...@ds...] Sent: Thursday, February 11, 2010 10:39 PM To: sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? Brandon, You could also rename your main() to mymain() and generate the necessary startup code yourself in assembly. (Sorry for misspelling your name earlier.) Maarten > > On Feb 11, 2010, at 20:04 , Peter Van Epp wrote: > > > On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: > >> Well, it looks like I spoke too soon. > >> > >> SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. > > > > It is defined in main (and thus will be in the code generator > > somewhere I expect), and called from > > sdcc/device/lib/mcs51/crtstart.asm. I expect you would meed to > > modify the code generator to do what you want (or modify main.asm by hand). > > > I was afraid of that. I may take a stab at modifying the generator, just for fun. Does anyone have a git mirror of the repository? > ---------------------------------------------------------------------- > -------- SOLARIS 10 is the OS for Data Centers - provides features > such as DTrace, Predictive Self Healing and Award Winning ZFS. Get > Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Brandon F. <BFo...@mo...> - 2010-02-17 15:34:26
|
I've had a request to add a writeup of my bootloader adventure to the project wiki. Hopefully I'll get to it this weekend. I don't see a How-To section on the front wiki page, anyone mind if I add it? In case anyone is curious, or I'm too lazy to actually do the wiki bits, here's the gist I made with the relevant crtstart.asm and Makefile: http://gist.github.com/304594 On Feb 15, 2010, at 10:47 , Brandon Fosdick wrote: > I think I figured it out. > In addition to everything from my last message, I added a GSFINAL section to crtstart.asm with an "ljmp _bootloader" instruction. That seems to have put everything in the right place. > > Thanks for the help > > > -----Original Message----- > From: Brandon Fosdick [mailto:BFo...@mo...] > Sent: Friday, February 12, 2010 4:53 PM > To: sou...@ds...; sdc...@li... > Subject: Re: [Sdcc-user] Default linker script for mcs51? > > Ok, that got me a little further. I renamed main() to bootloader() and made a linker script that moves both HOME and CSEG. Then I made my own crtstart.asm that puts " ljmp __sdcc_gsinit_startup" at the reset vector, and changes __sdcc_gsinit_startup to jump to _bootloader instead of __sdcc_program_startup. > > Compiling and linking all of that gives me output that seems to do what I want. However, I noticed that main.asm has what appears to be code for initializing global variables. And it seems that normally this code is run after a jump to __sdcc_init_data and then there's a jump to __sdcc_program_startup after the initialization is finished. When I changed main() to bootloader() that last jump to __sdcc_program_startup went away. > > I'm trying to figure out how to get that initialization code to run. I can't jump to __sdcc_init_data because there's no jump after the initialization that will get me back to _bootloader. Any suggestions? > > (No worries, happens all the time) > > -----Original Message----- > From: Maarten Brock [mailto:sou...@ds...] > Sent: Thursday, February 11, 2010 10:39 PM > To: sdc...@li... > Subject: Re: [Sdcc-user] Default linker script for mcs51? > > Brandon, > > You could also rename your main() to mymain() and generate the necessary startup code yourself in assembly. > > (Sorry for misspelling your name earlier.) > > Maarten > >> >> On Feb 11, 2010, at 20:04 , Peter Van Epp wrote: >> >>> On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: >>>> Well, it looks like I spoke too soon. >>>> >>>> SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. >>> >>> It is defined in main (and thus will be in the code generator >>> somewhere I expect), and called from >>> sdcc/device/lib/mcs51/crtstart.asm. I expect you would meed to >>> modify the code generator to do what you want (or modify main.asm by hand). >> >> >> I was afraid of that. I may take a stab at modifying the generator, just for fun. Does anyone have a git mirror of the repository? >> ---------------------------------------------------------------------- >> -------- SOLARIS 10 is the OS for Data Centers - provides features >> such as DTrace, Predictive Self Healing and Award Winning ZFS. Get >> Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev >> _______________________________________________ >> Sdcc-user mailing list >> Sdc...@li... >> https://lists.sourceforge.net/lists/listinfo/sdcc-user >> > > > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Gregory G D. <dy...@pd...> - 2010-02-17 16:18:42
|
Thank you! I'm working on a project where I intend to do basically the same thing and this will jumpstart that effort. Greg -----Original Message----- From: sdc...@li... [mailto:sdc...@li...] On Behalf Of Brandon Fosdick Sent: Wednesday, February 17, 2010 9:34 AM To: sdc...@li... Subject: Re: [Sdcc-user] Default linker script for mcs51? I've had a request to add a writeup of my bootloader adventure to the project wiki. Hopefully I'll get to it this weekend. I don't see a How-To section on the front wiki page, anyone mind if I add it? In case anyone is curious, or I'm too lazy to actually do the wiki bits, here's the gist I made with the relevant crtstart.asm and Makefile: http://gist.github.com/304594 On Feb 15, 2010, at 10:47 , Brandon Fosdick wrote: > I think I figured it out. > In addition to everything from my last message, I added a GSFINAL section to crtstart.asm with an "ljmp _bootloader" instruction. That seems to have put everything in the right place. > > Thanks for the help > > > -----Original Message----- > From: Brandon Fosdick [mailto:BFo...@mo...] > Sent: Friday, February 12, 2010 4:53 PM > To: sou...@ds...; sdc...@li... > Subject: Re: [Sdcc-user] Default linker script for mcs51? > > Ok, that got me a little further. I renamed main() to bootloader() and made a linker script that moves both HOME and CSEG. Then I made my own crtstart.asm that puts " ljmp __sdcc_gsinit_startup" at the reset vector, and changes __sdcc_gsinit_startup to jump to _bootloader instead of __sdcc_program_startup. > > Compiling and linking all of that gives me output that seems to do what I want. However, I noticed that main.asm has what appears to be code for initializing global variables. And it seems that normally this code is run after a jump to __sdcc_init_data and then there's a jump to __sdcc_program_startup after the initialization is finished. When I changed main() to bootloader() that last jump to __sdcc_program_startup went away. > > I'm trying to figure out how to get that initialization code to run. I can't jump to __sdcc_init_data because there's no jump after the initialization that will get me back to _bootloader. Any suggestions? > > (No worries, happens all the time) > > -----Original Message----- > From: Maarten Brock [mailto:sou...@ds...] > Sent: Thursday, February 11, 2010 10:39 PM > To: sdc...@li... > Subject: Re: [Sdcc-user] Default linker script for mcs51? > > Brandon, > > You could also rename your main() to mymain() and generate the necessary startup code yourself in assembly. > > (Sorry for misspelling your name earlier.) > > Maarten > >> >> On Feb 11, 2010, at 20:04 , Peter Van Epp wrote: >> >>> On Thu, Feb 11, 2010 at 12:27:04PM +0100, Brandon Fosdick wrote: >>>> Well, it looks like I spoke too soon. >>>> >>>> SDCC is still dumping some non-vector stuff in the GSINIT and HOME segments. I see how I could use the linker to relocate GSINIT* segments to someplace else (or modify the mcs51 library). But I don't see how to relocate __sdcc_program_startup from HOME to CSEG. It doesn't seem to be defined anywhere in the lib directory that was installed with SDCC. >>> >>> It is defined in main (and thus will be in the code generator >>> somewhere I expect), and called from >>> sdcc/device/lib/mcs51/crtstart.asm. I expect you would meed to >>> modify the code generator to do what you want (or modify main.asm by hand). >> >> >> I was afraid of that. I may take a stab at modifying the generator, just for fun. Does anyone have a git mirror of the repository? >> ---------------------------------------------------------------------- >> -------- SOLARIS 10 is the OS for Data Centers - provides features >> such as DTrace, Predictive Self Healing and Award Winning ZFS. Get >> Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev >> _______________________________________________ >> Sdcc-user mailing list >> Sdc...@li... >> https://lists.sourceforge.net/lists/listinfo/sdcc-user >> > > > > ---------------------------------------------------------------------------- -- > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ---------------------------------------------------------------------------- -- > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ---------------------------------------------------------------------------- -- > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user ---------------------------------------------------------------------------- -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Sdcc-user mailing list Sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Brandon F. <BFo...@mo...> - 2010-02-21 14:37:32
|
Wiki page is at http://sourceforge.net/apps/trac/sdcc/wiki/Compile%20and%20link%20a%20bootloader%20using%20SDCC On Feb 17, 2010, at 16:34 , Brandon Fosdick wrote: > I've had a request to add a writeup of my bootloader adventure to the project wiki. Hopefully I'll get to it this weekend. I don't see a How-To section on the front wiki page, anyone mind if I add it? > > In case anyone is curious, or I'm too lazy to actually do the wiki bits, here's the gist I made with the relevant crtstart.asm and Makefile: http://gist.github.com/304594 |
From: Maarten B. <sou...@ds...> - 2010-02-21 16:40:13
|
Hi Brandon, You sure know how to make life difficult. Had you asked right away how to create a bootloader instead of how to relocate this and that I would have given totally different advice. First, a bootloader that doesn't redirect the interrupt vectors runs the risk of selfdestruction. If power fails after erasure of the first block and before the reset vector is written back, your device is dead. This is not something I would want to distribute to my clients. Second, after reading your wiki I think you would have accomplished the same thing with --code-loc for the bootloader and an added reset vector in asm in an ABSolute area with .org 0x0000. My advice would be to use --code-loc to move the application and keep the bootloader at 0x0000. Add an assembly written interrupt redirection table to the bootloader and keep it free of interrupts itself. The cost is only a little latency on the interrupt service routines. Greets, Maarten > Wiki page is at http://sourceforge.net/apps/trac/sdcc/wiki/Compile%20and%20link%20a%20bootloader%20using%20SDCC > > > On Feb 17, 2010, at 16:34 , Brandon Fosdick wrote: > > > I've had a request to add a writeup of my bootloader adventure to the project wiki. Hopefully I'll get to it this weekend. I don't see a How-To section on the front wiki page, anyone mind if I add it? > > > > In case anyone is curious, or I'm too lazy to actually do the wiki bits, here's the gist I made with the relevant crtstart.asm and Makefile: http://gist.github.com/304594 |
From: Brandon F. <BFo...@mo...> - 2010-02-21 17:19:45
|
My first message in this thread did mention the bootloader aspect of my situation, but I guess it wasn't clear enough. I certainly wasn't trying to make your life difficult. I have some overriding requirements that force my hand. For one, the application code needs to be useable without the bootloader. Power failure is a risk in this situation, but the device is powered by a non-removable battery, so the risk is acceptably small. I tried using --code-loc for the bootloader but couldn't figure out how to get an ABS area to build/link properly. I'm sure I was doing something obviously wrong, but I couldn't see it at the time. Thanks for the advice. Feel free to kill that wiki page if you think it's inappropriate. I thought I was helping. On Feb 21, 2010, at 17:40 , Maarten Brock wrote: > Hi Brandon, > > You sure know how to make life difficult. Had you asked > right away how to create a bootloader instead of how to > relocate this and that I would have given totally > different advice. > > First, a bootloader that doesn't redirect the interrupt > vectors runs the risk of selfdestruction. If power fails > after erasure of the first block and before the reset > vector is written back, your device is dead. This is not > something I would want to distribute to my clients. > > Second, after reading your wiki I think you would have > accomplished the same thing with --code-loc for the > bootloader and an added reset vector in asm in an > ABSolute area with .org 0x0000. > > My advice would be to use --code-loc to move the > application and keep the bootloader at 0x0000. Add an > assembly written interrupt redirection table to the > bootloader and keep it free of interrupts itself. The > cost is only a little latency on the interrupt service > routines. > > Greets, > Maarten > > >> Wiki page is at http://sourceforge.net/apps/trac/sdcc/wiki/Compile%20and%20link%20a%20bootloader%20using%20SDCC >> >> >> On Feb 17, 2010, at 16:34 , Brandon Fosdick wrote: >> >>> I've had a request to add a writeup of my bootloader adventure to the project wiki. Hopefully I'll get to it this weekend. I don't see a How-To section on the front wiki page, anyone mind if I add it? >>> >>> In case anyone is curious, or I'm too lazy to actually do the wiki bits, here's the gist I made with the relevant crtstart.asm and Makefile: http://gist.github.com/304594 > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Maarten B. <sou...@ds...> - 2010-02-21 19:42:55
|
Brandon, You certainly did not make my life difficult. I meant you made it difficult for yourself which is your full right of course ;) I apologize for sounding too harsh. I think the wiki is ok in itself, just a difficult solution where an easy one would suffice. That you didn't see the easy solution before is no problem, but do you see it now? If so, please adapt the wiki so others don't need to use the difficult route. I don't intend to kill the page and you sure were helping. We need that. Thank you, Maarten > My first message in this thread did mention the bootloader aspect of my situation, but I guess it wasn't clear enough. I certainly wasn't trying to make your life difficult. > > I have some overriding requirements that force my hand. For one, the application code needs to be useable without the bootloader. Power failure is a risk in this situation, but the device is powered by a non-removable battery, so the risk is acceptably small. > > I tried using --code-loc for the bootloader but couldn't figure out how to get an ABS area to build/link properly. I'm sure I was doing something obviously wrong, but I couldn't see it at the time. > > Thanks for the advice. Feel free to kill that wiki page if you think it's inappropriate. I thought I was helping. > > > On Feb 21, 2010, at 17:40 , Maarten Brock wrote: > > > Hi Brandon, > > > > You sure know how to make life difficult. Had you asked > > right away how to create a bootloader instead of how to > > relocate this and that I would have given totally > > different advice. > > > > First, a bootloader that doesn't redirect the interrupt > > vectors runs the risk of selfdestruction. If power fails > > after erasure of the first block and before the reset > > vector is written back, your device is dead. This is not > > something I would want to distribute to my clients. > > > > Second, after reading your wiki I think you would have > > accomplished the same thing with --code-loc for the > > bootloader and an added reset vector in asm in an > > ABSolute area with .org 0x0000. > > > > My advice would be to use --code-loc to move the > > application and keep the bootloader at 0x0000. Add an > > assembly written interrupt redirection table to the > > bootloader and keep it free of interrupts itself. The > > cost is only a little latency on the interrupt service > > routines. > > > > Greets, > > Maarten > > > > > >> Wiki page is at http://sourceforge.net/apps/trac/sdcc/wiki/Compile%20and%20link%20a%20bootloader%20using%20SDCC > >> > >> > >> On Feb 17, 2010, at 16:34 , Brandon Fosdick wrote: > >> > >>> I've had a request to add a writeup of my bootloader adventure to the project wiki. Hopefully I'll get to it this weekend. I don't see a How-To section on the front wiki page, anyone mind if I add it? > >>> > >>> In case anyone is curious, or I'm too lazy to actually do the wiki bits, here's the gist I made with the relevant crtstart.asm and Makefile: http://gist.github.com/304594 > > > > > > ------------------------------------------------------------------------------ > > Download Intel® Parallel Studio Eval > > Try the new software tools for yourself. Speed compiling, find bugs > > proactively, and fine-tune applications for parallel performance. > > See why Intel Parallel Studio got high marks during beta. > > http://p.sf.net/sfu/intel-sw-dev > > _______________________________________________ > > Sdcc-user mailing list > > Sdc...@li... > > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > |