Commit 3412247f authored by Astro's avatar Astro
Browse files

Merge MR !5

parents 05999272 236f8cbf
Pipeline #3200 failed
# Rust support for the card10 CCCamp15 badge
# Rust support for the card10 CCCamp19 badge
## Prerequisites
You need Rust Nightly and the arm-none-eabi-gcc toolchain, including libc.
You need rust nightly and a working setup to compile the card10
firmware including the matching libc.
### Arch Linux
1) For instructions how to setup rust please see `https://rustup.rs`.
sudo pacman -S arm-none-eabi-gcc arm-none-eabi-binutils arm-none-eabi-newlib
Please ensure that you installed the latest rust nightly toolchain
and add the `thumbv7em-none-eabi` target.
## Usage
```shell
rustup toolchain install nightly
rustup update
rustup target add thumbv7em-none-eabi --toolchain nightly
```
You need Rust nightly. Use rustup or NixOS.
2) For instructions how to setup the card10 firmware check the dependency
chapter in `https://firmware.card10.badge.events.ccc.de/how-to-build.html`.
```shell
rustup update nightly
rustup override set nightly
rustup target add thumbv7em-none-eabi
```
When cloning use `--recursive` to get the submodules, otherwise update them
afterwards:
3) Additionally you may need the packages for the llvm and libc i386
dev headers.
4) Clone this repository with `--recursive` to get the submodules,
otherwise update them afterwards:
```shell
git submodule update --init --recursive
```
## Setup a Rust enabled firmware
To allow rust based apps on card10 you need a firmware which allows
to run custom elf binaries on the core. This requires a custom build
with `-Djailbreak_card10=true` as bootstrapping flag.
Assuming that you installed all required dependencies mentioned in
`https://firmware.card10.badge.events.ccc.de/how-to-build.html` this
should work as following:
```shell
git submodule update --init --recursive
cd c/
./bootstrap -Djailbreak_card10=true
ninja -C build/
```
Check out this repo's submodule (the C firmware).
And then copy `build/pycardium/pycardium_epicardium.bin` as
`card10.bin` onto your badge.
## Build and run Rust loadables
```shell
cd example
cargo build --release
cd example/
cargo +nightly build --release --target thumbv7-none-eabi
```
Then copy the resulting
`../target/thumbv7em-none-eabi/release/l0dable-example` to the badge
in USB Mass Storage mode in the `/apps/` subfolder. Don't forget to
rename with the `.elf` extension!
Then copy the resulting executable from the target directory
`../target/thumbv7em-none-eabi/release/l0dable-example` into the
`apps` directory of your badge.
**Attention**: Its necessary to rename the executable to add the
`elf` extension (e.g `l0adable-example` must be renamed as
`l0adable-example.elf`).
## Crates
......@@ -43,6 +70,23 @@ rename with the `.elf` extension!
| example | l0dable example |
| l0dable | Helpers for building l0dables |
## Misc
### How to update the firmware
1) Update the `c/` submodule to the latest firmware state.
2) Rebuild the firmware as described above.
3) Run the following script from the project root directory
```shell
python c/epicardium/api/genapi.py -H c/epicardium/epicardium.h -c l0dable/src/client.c -s l0dable/src/server.c
```
4) Rebuild your app :)
## TODO
- [ ] alloc
Subproject commit ea85141fe8993084882ffb945112e6891318f153
Subproject commit e6a8dac48796df88fdd84a2141b572068cc5960e
......@@ -259,7 +259,7 @@ int epic_gpio_write_pin(uint8_t pin, _Bool on)
}
/* Autogenerated stub for API_GPIO_READ_PIN */
uint32_t epic_gpio_read_pin(uint8_t pin)
int epic_gpio_read_pin(uint8_t pin)
{
const int epc__apistub_size = sizeof(uint8_t);
void*epc__apistub_buffer;
......@@ -269,7 +269,7 @@ uint32_t epic_gpio_read_pin(uint8_t pin)
*(uint8_t*)(epc__apistub_buffer + 0) = pin;
return *(uint32_t*)_api_call_transact(epc__apistub_buffer);
return *(int*)_api_call_transact(epc__apistub_buffer);
}
/* Autogenerated stub for API_LEDS_SET */
......@@ -812,6 +812,20 @@ int epic_disp_framebuffer(union disp_framebuffer *fb)
return *(int*)_api_call_transact(epc__apistub_buffer);
}
/* Autogenerated stub for API_DISP_BACKLIGHT */
int epic_disp_backlight(uint16_t brightness)
{
const int epc__apistub_size = sizeof(uint16_t);
void*epc__apistub_buffer;
epc__apistub_buffer = _api_call_start(API_DISP_BACKLIGHT, epc__apistub_size);
/* TODO: Check if epc__apistub_buffer is not NULL */
*(uint16_t*)(epc__apistub_buffer + 0) = brightness;
return *(int*)_api_call_transact(epc__apistub_buffer);
}
/* Autogenerated stub for API_LIGHT_SENSOR_RUN */
int epic_light_sensor_run()
{
......@@ -1057,6 +1071,19 @@ uint32_t epic_rtc_get_seconds(void)
return *(uint32_t*)_api_call_transact(epc__apistub_buffer);
}
/* Autogenerated stub for API_RTC_GET_MILLISECONDS */
uint64_t epic_rtc_get_milliseconds(void)
{
const int epc__apistub_size = 0;
void*epc__apistub_buffer;
epc__apistub_buffer = _api_call_start(API_RTC_GET_MILLISECONDS, epc__apistub_size);
/* TODO: Check if epc__apistub_buffer is not NULL */
return *(uint64_t*)_api_call_transact(epc__apistub_buffer);
}
/* Autogenerated stub for API_RTC_SET_MILLISECONDS */
void epic_rtc_set_milliseconds(uint64_t milliseconds)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment