Coder Social home page Coder Social logo

joydev-horst / m5stamp-c3dev Goto Github PK

View Code? Open in Web Editor NEW

This project forked from h1romas4/m5stamp-c3dev

0.0 0.0 0.0 3.68 MB

This is a development board for the M5Stamp C3 (RISC-V/FreeRTOS).

Home Page: https://another.maple4ever.net/archives/2979/

License: MIT License

Shell 21.01% JavaScript 9.59% C++ 37.62% C 4.25% TypeScript 15.98% CSS 1.25% HTML 1.12% CMake 9.19%

m5stamp-c3dev's Introduction

m5stamp-c3dev

Main Board

This is a development board for the M5Stamp C3 (RISC-V/FreeRTOS).

Hardware

  • External USB-C port for JTAG debugging
  • Support for LCD panel and SD card
  • Selecting a power supply
  • Switch(GPIO9) to enter loader mode
  • Pin headers to expose usable GPIOs to the outside
  • The size is just Japanese business card

Sample Sources Included

AssemblyScript and Wasm3

AssemblyScript and Wasm3

  • TrueType font with Japanese output to LCD - test_freetype.cpp
  • Output PNG images in SD card to LCD - test_tinypng.cpp
  • NTP synchronization via WiFi connection - test_nvs_wifi.cpp
  • Test ADC on GPIO0
  • Test I2C on GPIO18, 19
  • Test UART on GPIO18, 19
  • Test DIGITAL on GPIO18, 19
  • WebAssembly execution with Wasm3
  • Support RGB LED (SK6812) - main.cpp
  • Usage of SPIFFS, which stores TrueType fonts and .wasm binaries (parttool.py and spiffsgen.py tools)
  • Use of NVS (cryptographically enabled key value store) that stores WiFi passwords (nvs_partition_gen.py tool)
  • Building libraries and managing dependencies using the esp-idf build system
  • Visual Studio Code C/C++ Extention configuration and JTAG debugging configuration in conjunction with openocd
  • AssembyScript sharing method between web browser and microcontroller - wasm

This repository contains MIT Licensed PCB data and example programs.

Demo

Video

Web Simulation

Schematic

Circuit Diagram

#Unit Name Note Where to get it
U1 AE-USB2.0-TYPE-C USB 2.0 Type-C Break out board akizukidenshi.com (JP)
U2 M5STAMP-C3 M5Stamp C3 + M5Stack
+ SWITCH SCIENCE (JP)
U3 KMR-1.8SPI KMR-1.8 SPI marked LCD and SD card interface + amazon.co.jp (1)
+ ja.aliexpress.com
R1 - R2 5.2K Resistor Pull-down for USB Power supply -
R3 - R7 10K Resistor SPI pull-up -
JP1 Jumper pin Select external power supply akizukidenshi.com (JP)
SW1 Tact switch for loader mode and utility akizukidenshi.com (JP)
J1 12 Pin header You can use the one that comes with the M5Stamp C3 Mate -

PCB and Gerber data

Example Source

Require

get_idf or (Windows) ESP-IDF 4.4.2 command prompt

# Linux or macOS ->
$ alias get_idf='. $HOME/esp/esp-idf/export.sh'
$ get_idf
# <-

Detecting the Python interpreter
... snip ...
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

$ echo ${IDF_PATH}
/home/hiromasa/devel/toolchain/esp/esp-idf

$ riscv32-esp-elf-gcc -v
Using built-in specs.
COLLECT_GCC=riscv32-esp-elf-gcc
... snip ...
gcc version 8.4.0 (crosstool-NG esp-2021r2)

openocd (Optional)

$ openocd
Open On-Chip Debugger  v0.10.0-esp32-20211111 (2021-11-10-21:40)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html

Build and Execute

git clone and build

git clone --recursive https://github.com/h1romas4/m5stamp-c3dev
cd m5stamp-c3dev
idf.py build flash

Note: If you get a compile error, change the sdkconfig back to the Git one. In some cases, the target of sdkconfig is changed to esp32 instead of eps32c3.

Write TypeType font to SPIFFS

parttool.py write_partition --partition-name=font --partition-subtype=spiffs --input resources/spiffs_font.bin

Write WebAssembly(.wasm) to SPIFFS

parttool.py write_partition --partition-name=wasm --partition-subtype=spiffs --input resources/spiffs_wasm.bin

Setup WiFi (Optional)

  1. Change WiFi Setting

nvs_partition.csv: Set own [ssid], [password]

key,type,encoding,value
wifi,namespace,,
ssid,data,string,[ssid]
passwd,data,string,[password]
  1. Create NVS Partation file
python ${IDF_PATH}/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate nvs_partition.csv nvs_partition.bin 0x6000
  1. Write NVS Partation
esptool.py write_flash 0x9000 nvs_partition.bin

Restart M5Stamp C3 (NTP synchronization is performed by pressing the SW1 after the startup logo)

idf.py monitor

Select connected GPIO18 and GPIO19 device

idf.py menuconfig

C3DEV Configuration โ†’ Select GPIO 18/19

JTAG debug with Visual Studio Code

  1. Set ESP32_TOOLCHAIN_HOME
$ echo ${ESP32_TOOLCHAIN_HOME}
/home/hiromasa/.espressif/tools/riscv32-esp-elf
  1. Connect the PC to the USB Type-C of the U1
  2. Open the source file in Visual Studio Code.
  3. Run Task "openocd (debug)" @see .vscode/tasks.json
  4. Set a breakpoint in the source code.
  5. Debug Launch (GDB) @see .vscode/launch.json The first time you start the program, it will often fail, so if you get an error, retry.

vscode

Note

If the LCD color is inverted.

main/main.cpp

    // If the color is inverted, set to 1.
    tft.invertDisplay(0);
    // tft.invertDisplay(1);

Create SPIFFS parteation file

python ${IDF_PATH}/components/spiffs/spiffsgen.py 0x100000 resources/font resources/spiffs_font.bin
python ${IDF_PATH}/components/spiffs/spiffsgen.py 0x10000 resources/wasm resources/spiffs_wasm.bin

Change the output destination of the log to U1 Serial/JTAG.(Don't forget to put it back)

Component config โ†’ ESP System Settings โ†’ Channel for console output

idf.py menuconfig

vscode

AssemblyScript and Wasm3

Build AssemblyScript

cd wasm/clockenv # or cd wasm/gpsgsv
npm install

Web Browser Development

npm run asbuild:web
npm run start
# http://localhost:1234/

SPIFFS Build and Flash

npm run asbuild
cd ../../
python ${IDF_PATH}/components/spiffs/spiffsgen.py 0x10000 resources/wasm resources/spiffs_wasm.bin
parttool.py write_partition --partition-name=wasm --partition-subtype=spiffs --input resources/spiffs_wasm.bin

Dependencies

Thanks for all the open source.

Name Version License
esp-idf v4.4.2 BSD License
arduino-esp32 2.0.4 LGPL-2.1 License
M5EPD 0.1.4 FreeType Part(The FreeType License)
UNIT_ENV 0.0.5 MIT License
M5Unit-Sonic 0.0.2 MIT License
Adafruit_GFX 1.11.3 BSD License
Adafruit_BusIO 1.13.1 MIT License
Adafruit-ST7735-Library 1.9.3 MIT License
Adafruit_NeoPixel 1.10.5 LGPL-3.0 License
tinyPNG 0.11 MIT License
lwgps v2.1.0 MIT License
IRremoteESP8266 v2.8.2 LGPL-2.1 license
Wasm3 master(dc9fa49) MIT License
AsselblyScript 0.20.16 Apache-2.0 License
ๆบ็œŸใ‚ดใ‚ทใƒƒใ‚ฏ - SIL Open Font License 1.1

License

MIT License (includes PCB data and example source)

m5stamp-c3dev's People

Contributors

h1romas4 avatar maxgraey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.