Fixing RAM calculator and reduced actual SRAM usage

- Changed static variables to const that should have been const
- Updated CMake files to prepare for MCHCK custom bootloader
- Changed the USB ID numbers and ID number for bootloader
- Only generate DFU or Teensy binary image, not both
- Fixed RAM and FLASH calculator
- Added missing license in delay.c/h (much of it was taken from Teensy source though I've changed a bunch of it)
- Prepared mk20dx.c for upcoming bootloader addition
- mk20dx.h cleanup
- Reduced the MCHCK based flash size for the application image (bootloader changes requires more flash space)
- Fixed bugs in macro.c
- Added keyHold cli command
- Added show pending events debug message for PartialMap macro module
This commit is contained in:
Jacob Alexander 2014-08-15 10:42:12 -07:00
parent 2f7e3cb117
commit eabb1c546a
24 changed files with 418 additions and 110 deletions

View file

@ -34,8 +34,13 @@ set( MCU "${CHIP}" ) # For loading script compatibility
#| Chip Size Database
#| MCHCK Based
if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
set( SIZE_RAM 16384 )
set( SIZE_FLASH 126976 )
#| Teensy 3.0
if ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx128vlf5" )
elseif ( "${CHIP}" MATCHES "mk20dx128" )
set( SIZE_RAM 16384 )
set( SIZE_FLASH 131072 )
@ -84,12 +89,18 @@ message( "${COMPILER_SRCS}" )
#| USB Defines, this is how the loader programs detect which type of chip base is used
if ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx256" )
set( VENDOR_ID "0x16C0" )
set( PRODUCT_ID "0x0487" )
elseif ( "${CHIP}" MATCHES "mk20dx128vlf5" )
set( VENDOR_ID "0x2323" )
set( PRODUCT_ID "0x0001" )
if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
set( VENDOR_ID "0x1C11" )
set( PRODUCT_ID "0xB04D" )
set( BOOT_VENDOR_ID "0x1C11" )
set( BOOT_PRODUCT_ID "0xB007" )
set( DFU 1 )
elseif ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx256" )
set( VENDOR_ID "0x1C11" )
set( PRODUCT_ID "0xB04D" )
set( BOOT_VENDOR_ID "0x16c0" ) # TODO Double check, this is likely incorrect
set( BOOT_PRODUCT_ID "0x0487" )
set( TEENSY 1 )
endif ()
@ -98,18 +109,24 @@ endif ()
#| gnu89 = c89 plus GCC extensions
#| c99 = ISO C99 standard (not yet fully implemented)
#| gnu99 = c99 plus GCC extensions
set( CSTANDARD "-std=gnu99" )
#| gnu11 = c11 plus GCC extensions
set( CSTANDARD "-std=gnu11" )
#| Warning Options
#| -Wall...: warning level
set( WARN "-Wall -g" )
set( WARN "-Wall -ggdb3" )
#| Tuning Options
#| -f...: tuning, see GCC manual
#| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently
set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin" )
if( BOOTLOADER )
set( TUNING "-D_bootloader_ -Wno-main -msoft-float -mthumb -fplan9-extensions -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin" )
#set( TUNING "-mthumb -fdata-sections -ffunction-sections -fno-builtin -msoft-float -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -fwhole-program -Wno-main -nostartfiles -fplan9-extensions -D_bootloader_" )
else()
set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin -nostartfiles" )
endif()
#| Optimization level, can be [0, 1, 2, 3, s].
@ -136,7 +153,14 @@ add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING}
#| Linker Flags
set( LINKER_FLAGS "-mcpu=${CPU} -Wl,-Map=link.map,--cref -Wl,--gc-sections -mthumb -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld -nostartfiles" )
if( BOOTLOADER )
# Bootloader linker flags
set( LINKER_FLAGS "${TUNING} -Wl,--gc-sections -fwhole-program -T${CMAKE_CURRENT_SOURCE_DIR}/../Lib/${CHIP}.bootloader.ld -nostartfiles -Wl,-Map=link.map" )
#set( LINKER_FLAGS "-Wl,-Map=link.map,--cref -Wl,--gc-sections -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/../Lib/${CHIP}.bootloader.ld" )
else()
# Normal linker flags
set( LINKER_FLAGS "-Wl,-Map=link.map,--cref -Wl,--gc-sections -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld" )
endif()
#| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)

View file

@ -36,6 +36,10 @@ message( STATUS "MCU Selected:" )
message( "${MCU}" )
#| Indicate to later build step that this is a Teensy
set( Teensy )
#| Chip Size Database
#| Teensy 1.0
if ( "${CHIP}" MATCHES "at90usb162" )
@ -80,8 +84,10 @@ message( "${CPU}" )
#| USB Defines
set( VENDOR_ID "0x16C0" )
set( PRODUCT_ID "0x047D" )
set( VENDOR_ID "0x1C11" )
set( PRODUCT_ID "0xB04D" )
set( BOOT_VENDOR_ID "0x16C0" ) # TODO Double check, this is likely incorrect
set( BOOT_PRODUCT_ID "0x047D" )
#| Compiler flag to set the C Standard level.

View file

@ -50,7 +50,7 @@ if ( EXISTS compiler )
endif ()
#| Load the compiler family specific configurations
include( Lib/CMake/${COMPILER_FAMILY}.cmake )
include( ${COMPILER_FAMILY} )
#| Binutils not set by CMake
set( CMAKE_SIZE "${_CMAKE_TOOLCHAIN_PREFIX}size" )

View file

@ -129,6 +129,14 @@ message( "${DEBUG_SRCS}" )
###
# CMake Module Checking
#
find_package( Git REQUIRED )
find_package( Ctags ) # Optional
###
# Generate USB Defines
#
@ -240,13 +248,6 @@ ModuleCompatibility( ${DebugModulePath} ${DebugModuleCompatibility} )
###
# CMake Module Checking
#
find_package( Git REQUIRED )
find_package( Ctags ) # Optional
###
# ctag Generation
#
@ -287,19 +288,23 @@ set_target_properties( ${TARGET_ELF} PROPERTIES
#| Convert the .ELF into a .bin to load onto the McHCK
set( TARGET_BIN ${TARGET}.bin.dfu )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
COMMENT "Creating binary file to load: ${TARGET_BIN}"
)
if( DEFINED DFU )
set( TARGET_BIN ${TARGET}.dfu.bin )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
COMMENT "Creating dfu binary file: ${TARGET_BIN}"
)
endif()
#| Convert the .ELF into a .HEX to load onto the Teensy
set( TARGET_HEX ${TARGET}.teensy.hex )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
)
if ( DEFINED TEENSY )
set( TARGET_HEX ${TARGET}.teensy.hex )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
)
endif()
#| Generate the Extended .LSS
@ -331,8 +336,8 @@ add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
#| After Changes Size Information
add_custom_target( SizeAfter ALL
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ihex ${TARGET_ELF} ${SIZE_RAM} " SRAM"
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ihex ${TARGET_HEX} ${SIZE_FLASH} "Flash"
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ram ${TARGET_ELF} ${SIZE_RAM} " SRAM"
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} flash ${TARGET_ELF} ${SIZE_FLASH} "Flash"
DEPENDS ${TARGET_ELF}
COMMENT "Chip usage for ${CHIP}"
)

View file

@ -2,15 +2,24 @@
#| Jacob Alexander 2014
#| Arg List
#| 1 - size binary (e.g. avr-size)
#| 2 - target binary (e.g. ihex)
#| 2 - measurement type (flash or ram)
#| 3 - binary file (e.g. kiibohd.hex)
#| 4 - total available (flash/ram) in bytes
#| 5 - flash/ram
#| 5 - flash/ram text
# Looks for the data column, to get the flash/ram used (in bytes)
# <size binary> --target=<target binary> <binary file> | cut -f2 | tail -n 1
USED=$("$1" --target="$2" "$3" | cut -f2 | tail -n 1)
case "$2" in
"flash")
USED=$("$1" "$3" | tail -n-1 | awk '{ print $1+$2 }')
;;
"ram")
USED=$("$1" "$3" | tail -n-1 | awk '{ print $2+$3 }')
;;
*)
echo "INVALID Measurement type: $2"
exit 1
esac
# Calculates the total flash/ram used
TOTAL="$4"
@ -35,7 +44,7 @@ fi
# Displays Results
NAME="$5"
echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m ${USED}/${TOTAL}\tbytes"
echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m \t${USED}/${TOTAL}\tbytes"
exit 0