Comments (8)
I think you would be hard pressed to make many modifications to the current code as it is pretty close to the 1k limit. If you are you willing to let it get larger than 1K you could write some data into a specific ram location and have the gdb_bootloader main code look at that location to decide if the gdb code should start.
from fabooh.
Ahh, is RAM preserved across RESETs?
Or, exposing a call address should not add any extra code.
Also, hooking the bootloader to NMI (as per some compile-time config options) should be free, size-wise. (Useful if the fw doesn't use NMI otherwise.)
Or do I misunderstand something?
from fabooh.
The gdb_bootloader code uses a custom c runtime startup routine. It doesn't touch ram, nor does it use a data section. It does however initialize the stack to the top of ram. You can see the code here:
https://github.com/RickKimball/fabooh/blob/master/include/msp430/core/main.h#L126
So if you use memory at the lower end ( 0x200 ... ) it will be there when you reset. Here is the memory map used by the linker script for the gdb_bootloader:
https://github.com/RickKimball/fabooh/blob/master/board/msp430g2553in20/apps/gdb_bootloader/msp430g2553in20/_memory.x#L5
I would probably use a couple bytes with a magic word and the inverse of your magic word to trigger.
from fabooh.
It is pretty tight .. maybe ~40 bytes left for code
$ msp430-size gdb_bootloader.elf
text data bss dec hex filename
1048 0 66 1114 45a gdb_bootloader.elf
from fabooh.
Yeah, I know, thanks! I've also seen the memory map and the code, I'm just not familiar with the bootstrap stuff in general (and I didn't know the chip itself has a promise to keep the RAM intact across resets).
I just hoped that checking for being called via NMI might be cheap, considering code-size.
Or, it'd still also be configurable compile-time, with no GPIO checking code in NMI mode.
from fabooh.
(Also, I could replace the LED stuff with memory reads in a copy of the bootloader code if I wanted (I can still check BSL mode "visually" from UART, sending e.g. $#12 and receiving a '-'), but still would prefer a "free" (less intrusive) alternative without code changes, which an exposed call address could probably do. I guess it's easier with assembly than C, I'm not sure if it's even possible with GCC without contorted tricks.)
from fabooh.
This fits:
diff --git a/board/msp430g2553in20/apps/gdb_bootloader/gdb_bootloader.cpp b/board/msp430g2553in20/apps/gdb_bootloader/g
index a7daa55..af8483a 100644
--- a/board/msp430g2553in20/apps/gdb_bootloader/gdb_bootloader.cpp
+++ b/board/msp430g2553in20/apps/gdb_bootloader/gdb_bootloader.cpp
@@ -51,7 +51,7 @@
#if 1 /* might need to comment this out to gain space for the software only UART */
__attribute__((section(".copyr"),used))
const char _copyright[] = {
- "Copyright \xC2\xA9 2013 Kimball Software"
+ "Copyright \xC2\xA9 KimballSoftware"
};
#endif
@@ -124,7 +124,7 @@ void gdb_bootloader() {
PUSH2::setmode_inputpullup();
// if user didn't press button P1.3, just run from the user reset vector
- if ( !PUSH2::is_low() ) {
+ if ( !(PUSH2::is_low() || (*(uint16_t *)0x0200 == 0xb002)) ) {
register unsigned work_reg = USER_RESET_VECTOR; // check for valid user vector in flash hiding spot
// TODO: probably should reset clock and P1.3 button
@@ -140,6 +140,7 @@ void gdb_bootloader() {
);
}
}
+ *(unsigned *)0x200 = 0x0;
RED_LED::setmode_output();
RED_LED::high();
diff --git a/examples/basic/blink/blink.cpp b/examples/basic/blink/blink.cpp
index 99bffc1..7f587e2 100644
--- a/examples/basic/blink/blink.cpp
+++ b/examples/basic/blink/blink.cpp
@@ -6,6 +6,7 @@
void setup(void) {
RED_LED::setmode_output();
+ PUSH2::setmode_inputpullup();
}
void loop(void) {
@@ -13,6 +14,11 @@ void loop(void) {
const uint32_t msec_delay = 1000 / freq / 2;
while (1) {
+ if ( PUSH2::is_low() ) {
+ *(unsigned *)0x0200 = 0xb002;
+ WDTCTL = 0;
+ while(1);
+ }
RED_LED::toggle();
delay(msec_delay);
}
from fabooh.
OK, I like it, thanks! :) I'll close the issue.
(In the meantime, I finally realized that the bootloader must be started via RESET, since it itself also relies on a clean PUC state for proper init, so direct jumping or NMI wouldn't cut it for a generic code branch.)
from fabooh.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabooh.