Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
Badger 2040 2 Factor Authanticator TOTP/HOTP
TOTP/HOTP implementation for Badger 2040.
Prerequisite
I have gathered all the required dependencies for developing C++ programs for Badger 2040 and created a bootstrap script to do the heavy lifting. However, the prerequisites are as listed below.
- Common dependencies
gitcmakemakeninja-build
- Build dependencies for Fedora
gcc-arm-linux-gnuarm-none-eabi-gcc-cs-c++arm-none-eabi-gcc-csarm-none-eabi-binutilsarm-none-eabi-newlib
- Build dependencies for Ubuntu
gcc-arm-none-eabibuild-essentialgcc-arm-none-eabi
- Project dependencies
Project Related FAQs
How to create a new Badger 2040 program?
This part explains how to properly arrange source code for a Badger 2040 program for easy compiling and maintenance.
-
Clone the unmodified programexample directory and rename it (let it be
example-too). -
Add your source code files to the directory.
-
Modify the CMakeLists.txt in the new program directory to add source files and required options.
-
Add the following line at the end of this project's CMakeLists.txt
add_subdirectory(example-too)
How to build the program?
If you have used the supplied bootstrap script, you should be able to see the build folder, please follow from steps in that case.
-
Install all the build dependencies for your distro and initialize all the submodules. Run the following command in the project root and then inside all three submodules
pico-sdk,pico-extras,pimoroni-pico.git submodule update --init -
Create a
builddirectory.mkdir build && cd build -
Generate CMake project. (Note: using Ninja for speedy compilation.)
cmake .. -DPICO_BOARD=pimoroni_badger2040 -GNinja -
Compile your project. Do not compile the whole project, only compile the project you need by specifying the name.
ninja <program-name>
How to flash the programs to Badger 2040?
The Badger 2040 uses .ef2 files to flash any program. You can upload MicroPython, CircuitPython or custom-built images. Follow these steps to use your custom build images. You can add only one file at a time.
- Hold
boot/usrbutton on your badger and connect to your system. It will get mounted as RPI-RP2. There will be two files already, do not touch them. - Go to the build directory and find the corresponding
<project-name>.ef2file for your project. - Copy this file to the mounted RPI-RP2.
- Your badger screen will flash and the program will load.
- You can now test your program.
References
Where to buy Badger 2040?
Important Repositories
Acknowledgments
- Original Pico C++ Boilerplate Project
- Compiling Raspberry Pi Pico C/C++ programs on Fedora by John Walicki
- The Badger Set - small C++ programs for the Badger2040 by Michael Bell
License
I've added the BSD 3-Clause License to match the license used in the project dependencies. You should review this and check it's appropriate for your project before publishing your code.