diff options
author | cpldcpu <cpldcpu@gmail.com> | 2014-03-06 11:55:52 +0100 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2014-03-06 11:55:52 +0100 |
commit | 340b130a1e8d560aa12f38264722cfaeb977b89c (patch) | |
tree | c578a7ffbc477f5d965788c3fedd9bbb74e66aae /commandline | |
parent | 7a1beac2f9daf4e538453b86db2311f85038ccb0 (diff) | |
download | micronucleus-340b130a1e8d560aa12f38264722cfaeb977b89c.tar.gz micronucleus-340b130a1e8d560aa12f38264722cfaeb977b89c.tar.bz2 micronucleus-340b130a1e8d560aa12f38264722cfaeb977b89c.zip |
commandline: Added patching of jmp to bootloader
Diffstat (limited to 'commandline')
-rw-r--r-- | commandline/builds/Windows/micronucleus.exe | bin | 123967 -> 27150 bytes | |||
-rw-r--r-- | commandline/library/micronucleus_lib.c | 18 |
2 files changed, 17 insertions, 1 deletions
diff --git a/commandline/builds/Windows/micronucleus.exe b/commandline/builds/Windows/micronucleus.exe Binary files differindex 7c34bcb..e52115e 100644 --- a/commandline/builds/Windows/micronucleus.exe +++ b/commandline/builds/Windows/micronucleus.exe diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c index 601b190..e2497c2 100644 --- a/commandline/library/micronucleus_lib.c +++ b/commandline/library/micronucleus_lib.c @@ -171,7 +171,23 @@ int micronucleus_writeFlash(micronucleus* deviceHandle, unsigned int program_siz "therefore the bootloader can not be inserted. Please rearrage your code.\n" ); return -1; - } + } + + // Patch in jmp to bootloader. + if (deviceHandle->bootloader_start > 0x2000) { + // jmp + unsigned data = 0x940c; + page_buffer [ 0 ] = data >> 0 & 0xff; + page_buffer [ 1 ] = data >> 8 & 0xff; + page_buffer [ 2 ] = deviceHandle->bootloader_start >> 0 & 0xff; + page_buffer [ 3 ] = deviceHandle->bootloader_start >> 8 & 0xff; + } else { + // rjmp + unsigned data = 0xc000 | ((deviceHandle->bootloader_start/2 - 1) & 0x0fff); + page_buffer [ 0 ] = data >> 0 & 0xff; + page_buffer [ 1 ] = data >> 8 & 0xff; + } + } if ( address >= deviceHandle->bootloader_start - deviceHandle->page_size ) { |