Also implement some ordering (quite ugly still) in the module init and task creation order so we can decide which module to start/init first
and which module to start/init last.
This will be replaced/adapter with the uavobject list later (once it's implemented).
reserving some space for module init and task create parameters to customize module/task creation (this will be usefull once we get the list and customization from customer).
Changes have been made for OP and CC. Tested comped with CC,OP, sim_posix.
Only ran on bench with CC for couple of minutes (code increase expected but no dropping of stack which is good).
This gives task creation at the time wherethe all heap is available.
This reverts commit 0ba605812e.
The real problem was not with this, but due to unexpected reverse
checkbox behaviour.
Reverse checkboxes are completely ignored at the start of calibration,
they can be even set checked initially. But change of checkbox does not
reverse the GCS control gadget display. This should probably be fixed.
For CopterControl the following make options are available:
USE_TELEMETRY=[YES|NO|1|3] (default is YES, USART1)
USE_GPS=[YES|NO|1|3] (default is NO, USART3)
USE_SPEKTRUM=[YES|NO|1|3] (default is NO, USART3)
USE_SBUS=[YES|NO|1] (default is NO, USART1 only)
heap reamining is low (about 500) but stacks can be ajusted (specially the 200 bytes from system) to give the level close to 1Ko if needed.
Merge branch 'master' into OP-423_Mathieu_Change_Init_To_Reduce_Memory_Footprint
Conflicts:
flight/CopterControl/System/inc/FreeRTOSConfig.h
flight/CopterControl/System/inc/pios_config.h
- create linker section for those <module>Initialize()
- later this list will incorporate parameters as well. (this probably will be more a OP feature to swap/remove/delete module on the fly.
- this is not done at compile time anymore by Makefile.
- this will allow us to have control on the module start at run-time (not implemented but build the ground for it).
- this simplify the startup (Part of code re-org).
- this change does not affect sim_posix and win32 (since they don't need that)
- ensure it's compiling for PiOS.posix
- port to PiOS.win32 but not tested (not compiled)
- tested on CC
- compile on OP.
- this free ~200 bytes.
- current avalable bytes (is we keep the same remaining bytes on the stack than before) is easily passed the 1.2Ko mark on CC with new gcc (4.5.2)
- this does not include init-reorg for each module (I still think more can be freed)
It was tested being merged with OP-472_CorvusCorax_CopterControl-Guidance_v3
branch, Spektrum on USART3 and GPS on USART1 and seems to work.
Currently defaults mimic original behavior, that is, if USE_SPEKTRUM
is not defined - define USE_PWM and USE_GPS. Thsi should be refactored
later to make it configurable from the Makefile.
Also it was not ported to the OP MB: it currently does not support the
S.Bus hardware and still has original behavior with the patch. But this
is one more step to dynamic configuration of ports.
Added new unbrick_<board> targets for each board.
These targets use the stm32flash utility to install
a bootloader on to the board. This is a tool of
last resort and should not be used for normal firmware
upgrades.
Usage:
make unbrick_<board> UNBRICK_TTY=/dev/ttyUSB0
Where:
<board> is one of coptercontrol, pipxtreme,
openpilot, ins, ahrs
UNBRICK_TTY is set to the serial device connected
to the board.
This tool can be used as a last resort for
installing a bootloader to a completely bricked
board that is unresponsive to even the rescue
functionality in the GCS uploader gadget.
TODO: This should be dynamic in the future.
But for now define any compatile combination of:
USE_I2C (shared with USART3)
USE_TELEMETRY
USE_GPS
USE_SPEKTRUM
USE_SBUS (USART1 only, it needs an invertor)
and optionally define PIOS_PORT_* to USART port numbers
Defaults are:
#define PIOS_PORT_TELEMETRY 1
#define PIOS_PORT_GPS 3
#define PIOS_PORT_SPEKTRUM 3
#define PIOS_PORT_SBUS 1
#define USE_TELEMETRY
#define USE_GPS
Telemetry, GPS and PWM input are enabled by default.
CAREFULL: the heap section need to be the last section in RAM to avoid overwritting data...
Tested with GCC 4.5.2 this gives 1K of free bytes usable in heap right away (including the 200 bytes saved just by using the new gcc).
This does not include any code re-org yet!
I managed to test CC with heap2 changes and the init stack claimed back to heap once scheduler starts.
the changes of this commit are OP related (just cleanup on CC side):
Arch specific stuff (in reset vector) to hide this from portable code:
- switch back to MSP stack before starting the scheduler so that the sheduler can use the IRQ stack (when/if needed).
- call the C portable function in heap2 to claim some stack back (the number to claim is taken from linker file).
- start the scheduler from reset vector (I move this here from main because it make sense to not go back to C (so that I don't need to copy the rolled stack in case the sheduler returns). This make it more clean.
- Also I have added the call to the mem manager if sheduler return. that way, we don't reset indefinitely if memory runs out. We will go to this handler and figure things out (right now, it's just looping but at least not rebooting. Probably trap NMI would be better (later improvement).