cherry-pick some stuff from 9aaa7ff on haskal/mechanical-fixes

This commit is contained in:
Triss 2021-06-28 21:19:46 +02:00
parent 414c0dfdee
commit a1c9327174
6 changed files with 43 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
cmake-build/
build/
ex/
compile_commands.json

View File

@ -84,8 +84,11 @@ target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/bsp/default/
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
add_custom_target(fix_db ALL WORKING_DIRECTORY ${OUTPUT_DIR}
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/fix_clang_db.py")
if(FAMILY STREQUAL "rp2040")
target_link_libraries(${PROJECT} pico_stdlib pico_unique_id hardware_spi

View File

@ -33,7 +33,7 @@ Compilation is done using CMake:
```
mkdir cmake-build && cd cmake-build
cmake -DBOARD=raspberry_pi_pico -DFAMILIY=rp2040 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
cmake -DBOARD=raspberry_pi_pico -DFAMILY=rp2040 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
```
`BOARD` and `FAMILY` should correspond to those used in the TinyUSB `hw` folder,
@ -54,7 +54,7 @@ the `-DUSE_SYSTEMWIDE_PICOSDK=On` flag to CMake, too.
Other options are:
* `-DPICO_NO_FLASH=[On|Off]`: store the binary in RAM only, useful for development.
* `-DPICO_COPY_TO_RAM=[On|Off]`: write to flash, but always run from RAM
* `-DUSE_USBCDC_FOR_STDIO=[On|Off]`: export an extra USB-CDC interface for debuggin
* `-DUSE_USBCDC_FOR_STDIO=[On|Off]`: export an extra USB-CDC interface for debugging
## Usage
@ -231,8 +231,9 @@ libco is licensed under the [ISC license](https://opensource.org/licenses/ISC)
- [x] CMSIS-DAP JTAG implementation
- [x] Flashrom/SPI support using Serprog
- [ ] Parallel ROM flashing support, too, by having the device switch into a
separate mode that temporarily disables all other IO protocols
- Parallel ROM flashing support, too, by having the device switch into a
separate mode that temporarily disables all other IO protocols
- Not enough IO, rip.
- [x] UART with CTS/RTS flow control
- [x] Needs configurable stuff as well, as some UART interfaces won't use this.
- [x] Debug interface to send printf stuff directly to USB, instead of having

View File

@ -7,7 +7,7 @@ def auto_int(x):
return int(x, 0)
class RTOpt(NamedTuple):
type: bool
type: Callable[[Any], Any]
optid: int
desc: str

14
scripts/configure_dev.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -eo pipefail
SCRIPTPATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
SRCPATH=$(readlink -e "$SCRIPTPATH/..")
cd "$SRCPATH"
[ -d "cmake-build" ] || mkdir cmake-build
cd cmake-build
set -x
exec cmake -G Ninja -DBOARD=raspberry_pi_pico -DFAMILY=rp2040 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DPICO_NO_FLASH=On -DUSE_USBCDC_FOR_STDIO=On -DUSE_SYSTEMWIDE_PICOSDK=On \
"$SRCPATH"

16
scripts/fix_clang_db.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
import json
import sys
with open("compile_commands.json", "r") as f:
data = json.load(f)
include = " -I/usr/arm-none-eabi/include"
for i in range(len(data)):
if include not in data[i]["command"]:
data[i]["command"] += include
with open("compile_commands.json", "w") as f:
json.dump(data, f)