Giter Site home page Giter Site logo

modm-io / modm Goto Github PK

View Code? Open in Web Editor NEW
697.0 697.0 121.0 46.79 MB

modm: a C++23 library generator for AVR and ARM Cortex-M devices

Home Page: https://modm.io

License: Mozilla Public License 2.0

Python 20.08% C 1.72% C++ 74.29% Makefile 0.23% Java 1.80% Shell 0.02% Smarty 1.27% CMake 0.23% HTML 0.03% CSS 0.32%
avr cortex-m cpp data-driven drivers embedded eurobot generator hal microcontroller microcontrollers modm stm32

modm's People

Contributors

andryblack avatar asmfreak avatar cajt avatar chris-durand avatar daniel-k avatar dergraaf avatar dhebbeker avatar ekiwi avatar georgi-g avatar henrikssn avatar hshose avatar javask avatar lukh avatar mbait avatar mcbridejc avatar mhthies avatar mikewolfram avatar nesos avatar rasmuskleist avatar rleh avatar salkinium avatar se-bi avatar sh4rk avatar strongly-typed avatar theth0r avatar thundernail avatar tomsaw avatar twasilczyk avatar victorandrehc avatar wasabifan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modm's Issues

"\n" creates a new line, but also adds spaces.

The "\n" or similar such as "modm::endl;" creates a new line, but also adds spaces. See picture below:
capture

#include <blink/common/board.hpp>
#include <blink/common/config.hpp>
#include <modm/debug/logger.hpp>

using namespace modm::platform;

modm::IODeviceWrapper<Usart2, modm::IOBuffer::BlockIfFull> loggerDevice;
modm::log::Logger modm::log::info(loggerDevice);

// Set the log level
#undef	MODM_LOG_LEVEL
#define	MODM_LOG_LEVEL modm::log::INFO


int main(void) {
	Board::initialize();
	modm::IOStream stream(loggerDevice);	

	//MODM_LOG_INFO<< "hello" <<modm::endl;
	while(true){
		if(Board::Button::read()){
			
			loggerDevice.write("hello");
			loggerDevice.write("\n");
		 	for (int i = 0; i < 2; i++) {
				Board::LedGreen::toggle();
				modm::delayMilliseconds(250);

			}
		}
	}
	
	return 0;
}

Mismatched declaration and implementation of _delay_ms/us/ns on cortex

In src/modm/platform/clock/cortex/delay.hpp, these functions are declared as accepting uint32_t arguments, but the implementation in delay.cpp uses uint16_t. I noticed this when I enabled link-time-optimization and GCC warned it might not produce correct code. Was there a reason behind this or can it be changed?

Latest develop version with lbuild 1.11.2 does not work

I just upgraded my lbuild and pulled the latest develop changes, and this is what I get:

d:\Prog\modm\examples\nucleo_f429zi\blink>lbuild -r ..\..\..\repo.lb build
Recomputing device cache...
[WARNING] lbuild.repository: Namespacing repository filter 'windowsify' to 'modm.windowsify'!
[WARNING] lbuild.repository: Namespacing repository filter 'ord' to 'modm.ord'!
[WARNING] lbuild.repository: Namespacing repository filter 'chr' to 'modm.chr'!

ERROR: Cannot resolve name 'd:\Prog\modm\examples\nucleo_f429zi\blink\project.xml' of type Config!

Hint: Did you use the full name?
      Is the Config available and selected?
      Check your command line and config files.


Current project configuration:

ConfigNode(filename='command-line')

Parser(lbuild)
╰── Repository(modm @ ..\..\..)   modm: a barebone embedded library generator
    ├── EnumerationOption(target) = REQUIRED in [at90can128, at90can32, at90can64, at90pwm1, at90pwm161, at90pwm2, a ...
    ├── Configuration(modm:al-avreb-can)   # AL-AVREB_CAN Board
    ├── Configuration(modm:arduino-nano)   Arduino NANO
    ├── Configuration(modm:arduino-uno)   Arduino UNO
    ├── Configuration(modm:black-pill)   # Black Pill
    ├── Configuration(modm:blue-pill)   # Blue Pill
    ├── Configuration(modm:disco-f051r8)   # STM32F0DISCOVERY
    ├── Configuration(modm:disco-f072rb)   # STM32F072DISCOVERY
    ├── Configuration(modm:disco-f100rb)   # STM32VLDISCOVERY
    ├── Configuration(modm:disco-f303vc)   # STM32F3DISCOVERY
    ├── Configuration(modm:disco-f407vg)   # STM32F4DISCOVERY
    ├── Configuration(modm:disco-f429zi)   # STM32F429IDISCOVERY
    ├── Configuration(modm:disco-f469ni)   # STM32F469IDISCOVERY
    ├── Configuration(modm:disco-f746ng)   # STM32F7DISCOVERY
    ├── Configuration(modm:disco-f769ni)   # STM32F769IDISCOVERY
    ├── Configuration(modm:disco-l476vg)   # STM32L476DISCOVERY
    ├── Configuration(modm:nucleo-f031k6)   # NUCLEO-F031K6
    ├── Configuration(modm:nucleo-f042k6)   # NUCLEO-F042K6
    ├── Configuration(modm:nucleo-f103rb)   # NUCLEO-F103RB
    ├── Configuration(modm:nucleo-f303k8)   # NUCLEO-F303K8
    ├── Configuration(modm:nucleo-f401re)   # NUCLEO-F401RE
    ├── Configuration(modm:nucleo-f411re)   # NUCLEO-F411RE
    ├── Configuration(modm:nucleo-f429zi)   # NUCLEO-F429ZI
    ├── Configuration(modm:nucleo-g071rb)   # NUCLEO-G071RB
    ├── Configuration(modm:nucleo-l432kc)   # NUCLEO-L432KC
    ├── Configuration(modm:nucleo-l476rg)   # NUCLEO-L476RG
    ├── Configuration(modm:olimexino-stm32)   # Olimexino STM32
    ╰── Configuration(modm:stm32f030_demo)   # STM32F030 Demo Board

Runtime configuration based Port/Pin assignments

Hi, I've been reading the documentation for quite a while now and cant really find an answer or example to my problem. I really like the idea of this library especially that it's really clean and seemingly easy to use although all the examples have the pin and port assignments set at compile time. My question would be; is that possible to use a dynamic configuration for pin assignments at runtime?
My use case is basically I have different board manufacturers and they wire the same peripherals to different ports/pins so I'd need to have a way to use different pins and even different peripherals based on configuration.
For example, board A has a peripheral connected to the SPI5 interface while board B uses SPI5 but on different pins while board C uses SPI3 instead of 5.
Is there a way to solve this with modm or is the library really tailored around compile time assignments?
Thank you

Support for ATSAM arm processors

The Atmel (Microchip) ATSAM line of ARM microprocessors are very nice microcontrollers. The SAMD21 is used on Arduino boards. Adafruit has SAMD21 and SAMD51 based feather boards. Peripherals are conceptually similar to the nicer AVR peripherals (SERCOM, timers, etc) and there is a lot of code/pinout compatibility between models.

I actually use the SAML21 processor on a few projects, which is a very low power M0+. I build very low power data-loggers for physiological experiments, and it seems like my use case has a large overlap with modm.

Perhaps I can help add support for these processors?

Python FutureWarning

root@b388c7a65654:/build/src# lbuild build
/usr/local/lib/python3.6/dist-packages/lbuild/config.py:138: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
  if cache_node:
modm requires at least lbuild v1.4.0, please upgrade!
    pip install -U lbuild

Is this an lbuild or mdom warning?

Adding CMake Support

I've tried to follow instructions and downloaded/installed everything according to documentation. Nevertheless, when I'm trying to launch lbuild discover-repository command inside modm/examples/stm32f103c8t6_blue_pill/blink, I'm getting following error:

ERROR in '/home/siy/CLionProjects/modm'
Traceback (most recent call last):
File "/home/siy/CLionProjects/modm/repo.lb", line 21, in
import modm.pkg
ImportError: No module named 'modm'

Also, there is almost no information on how to configure and build project with CMake. I'd like to extend this part of documentation, but I need some starting point, i.e. working build process (either with SCons or CMake).

TODOs and Ideas

Some rough ideas about what needs to be done without having to open an individual issue for each one of them. Please feel free to comment or add more features.

Library

Build

  • More flexible git info for any repository.

Nucleo L3 programming fails

Working example modm at 4ae989e

scons program verbose=1
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
openocd -s "/XXXXXXXXXXXXXXXXXXX/src/modm/openocd" -f "board/st_nucleo_f3.cfg" -c "init" -c "reset halt" -c "flash write_image erase build/src.elf" -c "reset halt" -c "mww 0xE000EDF0 0xA05F0000" -c "shutdown"
Open On-Chip Debugger 0.10.0+dev-00449-g4999c9d9 (2018-07-06-10:23)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v18 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.262426
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
adapter speed: 950 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800180c msp: 0x20000be0
auto erase enabled
Info : device id = 0x10016438
Info : flash size = 64kbytes
Info : Padding image section 1 at 0x080001e8 with 8 bytes
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000003a msp: 0x20000be0
Warn : no flash bank found for address 0x10000000
wrote 14336 bytes from file build/src.elf in 0.807490s (17.338 KiB/s)
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
adapter speed: 950 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800180c msp: 0x20000be0
shutdown command invoked
scons: done building targets.

Non-working example, after updating modm to ea7a300

scons program verbose=1
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
openocd -f "XXXXXXXXXXXXXXX/src/modm/openocd.cfg" -c "modm_program build/release/src.elf"
Open On-Chip Debugger 0.10.0+dev-00449-g4999c9d9 (2018-07-06-10:23)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
program_debug
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v18 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.264000
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
adapter speed: 950 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080018a0 msp: 0x20000be0
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
adapter speed: 4000 kHz
** Programming Started **
auto erase enabled
Info : device id = 0x10016438
Info : flash size = 64kbytes
Info : Padding image section 1 at 0x080001e8 with 8 bytes
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000003a msp: 0x20000be0
Warn : no flash bank found for address 0x10000000
wrote 14336 bytes from file build/release/src.elf in 0.654982s (21.375 KiB/s)
** Programming Finished **
** Verify Started **
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000be0
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000be0
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000be0
Error: checksum mismatch - attempting binary compare
diff 0 address 0x10000000. Was 0xe0 instead of 0x00
diff 1 address 0x10000001. Was 0x0b instead of 0x00
diff 2 address 0x10000003. Was 0x20 instead of 0x00
diff 3 address 0x10000004. Was 0x0d instead of 0x00
diff 4 address 0x10000005. Was 0x18 instead of 0x00
diff 5 address 0x10000007. Was 0x08 instead of 0x00
diff 6 address 0x10000008. Was 0xf5 instead of 0x00
diff 7 address 0x10000009. Was 0x18 instead of 0x00
diff 8 address 0x1000000b. Was 0x08 instead of 0x00
diff 9 address 0x1000000c. Was 0xf5 instead of 0x00
diff 10 address 0x1000000d. Was 0x18 instead of 0x00
diff 11 address 0x1000000f. Was 0x08 instead of 0x00
diff 12 address 0x10000010. Was 0xf5 instead of 0x00
diff 13 address 0x10000011. Was 0x18 instead of 0x00
diff 14 address 0x10000013. Was 0x08 instead of 0x00
diff 15 address 0x10000014. Was 0xf5 instead of 0x00
diff 16 address 0x10000015. Was 0x18 instead of 0x00
diff 17 address 0x10000017. Was 0x08 instead of 0x00
diff 18 address 0x10000018. Was 0xf5 instead of 0x00
diff 19 address 0x10000019. Was 0x18 instead of 0x00
diff 20 address 0x1000001b. Was 0x08 instead of 0x00
diff 21 address 0x1000001c. Was 0xf5 instead of 0x00
diff 22 address 0x1000001d. Was 0x18 instead of 0x00
diff 23 address 0x1000001f. Was 0x08 instead of 0x00
diff 24 address 0x10000020. Was 0xf5 instead of 0x00
diff 25 address 0x10000021. Was 0x18 instead of 0x00
diff 26 address 0x10000023. Was 0x08 instead of 0x00
diff 27 address 0x10000024. Was 0xf5 instead of 0x00
diff 28 address 0x10000025. Was 0x18 instead of 0x00
diff 29 address 0x10000027. Was 0x08 instead of 0x00
diff 30 address 0x10000028. Was 0xf5 instead of 0x00
diff 31 address 0x10000029. Was 0x18 instead of 0x00
diff 32 address 0x1000002b. Was 0x08 instead of 0x00
diff 33 address 0x1000002c. Was 0xf5 instead of 0x00
diff 34 address 0x1000002d. Was 0x18 instead of 0x00
diff 35 address 0x1000002f. Was 0x08 instead of 0x00
diff 36 address 0x10000030. Was 0xf5 instead of 0x00
diff 37 address 0x10000031. Was 0x18 instead of 0x00
diff 38 address 0x10000033. Was 0x08 instead of 0x00
diff 39 address 0x10000034. Was 0xf5 instead of 0x00
diff 40 address 0x10000035. Was 0x18 instead of 0x00
diff 41 address 0x10000037. Was 0x08 instead of 0x00
diff 42 address 0x10000038. Was 0xf5 instead of 0x00
diff 43 address 0x10000039. Was 0x18 instead of 0x00
diff 44 address 0x1000003b. Was 0x08 instead of 0x00
diff 45 address 0x1000003c. Was 0x99 instead of 0x00
diff 46 address 0x1000003d. Was 0x16 instead of 0x00
diff 47 address 0x1000003f. Was 0x08 instead of 0x00
diff 48 address 0x10000040. Was 0xf5 instead of 0x00
diff 49 address 0x10000041. Was 0x18 instead of 0x00
diff 50 address 0x10000043. Was 0x08 instead of 0x00
diff 51 address 0x10000044. Was 0xf5 instead of 0x00
diff 52 address 0x10000045. Was 0x18 instead of 0x00
diff 53 address 0x10000047. Was 0x08 instead of 0x00
diff 54 address 0x10000048. Was 0xf5 instead of 0x00
diff 55 address 0x10000049. Was 0x18 instead of 0x00
diff 56 address 0x1000004b. Was 0x08 instead of 0x00
diff 57 address 0x1000004c. Was 0xf5 instead of 0x00
diff 58 address 0x1000004d. Was 0x18 instead of 0x00
diff 59 address 0x1000004f. Was 0x08 instead of 0x00
diff 60 address 0x10000050. Was 0xf5 instead of 0x00
diff 61 address 0x10000051. Was 0x18 instead of 0x00
diff 62 address 0x10000053. Was 0x08 instead of 0x00
diff 63 address 0x10000054. Was 0xf5 instead of 0x00
diff 64 address 0x10000055. Was 0x18 instead of 0x00
diff 65 address 0x10000057. Was 0x08 instead of 0x00
diff 66 address 0x10000058. Was 0xf5 instead of 0x00
diff 67 address 0x10000059. Was 0x18 instead of 0x00
diff 68 address 0x1000005b. Was 0x08 instead of 0x00
diff 69 address 0x1000005c. Was 0xf5 instead of 0x00
diff 70 address 0x1000005d. Was 0x18 instead of 0x00
diff 71 address 0x1000005f. Was 0x08 instead of 0x00
diff 72 address 0x10000060. Was 0xf5 instead of 0x00
diff 73 address 0x10000061. Was 0x18 instead of 0x00
diff 74 address 0x10000063. Was 0x08 instead of 0x00
diff 75 address 0x10000064. Was 0xf5 instead of 0x00
diff 76 address 0x10000065. Was 0x18 instead of 0x00
diff 77 address 0x10000067. Was 0x08 instead of 0x00
diff 78 address 0x10000068. Was 0xf5 instead of 0x00
diff 79 address 0x10000069. Was 0x18 instead of 0x00
diff 80 address 0x1000006b. Was 0x08 instead of 0x00
diff 81 address 0x1000006c. Was 0xf5 instead of 0x00
diff 82 address 0x1000006d. Was 0x18 instead of 0x00
diff 83 address 0x1000006f. Was 0x08 instead of 0x00
diff 84 address 0x10000070. Was 0xf5 instead of 0x00
diff 85 address 0x10000071. Was 0x18 instead of 0x00
diff 86 address 0x10000073. Was 0x08 instead of 0x00
diff 87 address 0x10000074. Was 0xf5 instead of 0x00
diff 88 address 0x10000075. Was 0x18 instead of 0x00
diff 89 address 0x10000077. Was 0x08 instead of 0x00
diff 90 address 0x10000078. Was 0xf5 instead of 0x00
diff 91 address 0x10000079. Was 0x18 instead of 0x00
diff 92 address 0x1000007b. Was 0x08 instead of 0x00
diff 93 address 0x1000007c. Was 0xf5 instead of 0x00
diff 94 address 0x1000007d. Was 0x18 instead of 0x00
diff 95 address 0x1000007f. Was 0x08 instead of 0x00
diff 96 address 0x10000080. Was 0xf5 instead of 0x00
diff 97 address 0x10000081. Was 0x18 instead of 0x00
diff 98 address 0x10000083. Was 0x08 instead of 0x00
diff 99 address 0x10000084. Was 0xf5 instead of 0x00
diff 100 address 0x10000085. Was 0x18 instead of 0x00
diff 101 address 0x10000087. Was 0x08 instead of 0x00
diff 102 address 0x10000088. Was 0xf5 instead of 0x00
diff 103 address 0x10000089. Was 0x18 instead of 0x00
diff 104 address 0x1000008b. Was 0x08 instead of 0x00
diff 105 address 0x1000008c. Was 0xf5 instead of 0x00
diff 106 address 0x1000008d. Was 0x18 instead of 0x00
diff 107 address 0x1000008f. Was 0x08 instead of 0x00
diff 108 address 0x10000090. Was 0xf5 instead of 0x00
diff 109 address 0x10000091. Was 0x18 instead of 0x00
diff 110 address 0x10000093. Was 0x08 instead of 0x00
diff 111 address 0x10000094. Was 0xf5 instead of 0x00
diff 112 address 0x10000095. Was 0x18 instead of 0x00
diff 113 address 0x10000097. Was 0x08 instead of 0x00
diff 114 address 0x10000098. Was 0xf5 instead of 0x00
diff 115 address 0x10000099. Was 0x18 instead of 0x00
diff 116 address 0x1000009b. Was 0x08 instead of 0x00
diff 117 address 0x1000009c. Was 0xf5 instead of 0x00
diff 118 address 0x1000009d. Was 0x18 instead of 0x00
diff 119 address 0x1000009f. Was 0x08 instead of 0x00
diff 120 address 0x100000a0. Was 0xf5 instead of 0x00
diff 121 address 0x100000a1. Was 0x18 instead of 0x00
diff 122 address 0x100000a3. Was 0x08 instead of 0x00
diff 123 address 0x100000a4. Was 0xf5 instead of 0x00
diff 124 address 0x100000a5. Was 0x18 instead of 0x00
diff 125 address 0x100000a7. Was 0x08 instead of 0x00
diff 126 address 0x100000a8. Was 0xf5 instead of 0x00
diff 127 address 0x100000a9. Was 0x18 instead of 0x00
More than 128 errors, the rest are not printed.
embedded:startup.tcl:477: Error: ** Verify Failed **
in procedure 'modm_program'
in procedure 'program' called at file "/XXXXXXXXXXXXXXXXXXXXXXXXXX/src/modm/openocd.cfg", line 4
in procedure 'program_error' called at file "embedded:startup.tcl", line 522
at file "embedded:startup.tcl", line 477
scons: *** [openocd_run] Error 1
scons: building terminated because of errors.
cat modm/openocd.cfg
add_script_search_dir modm/openocd
source [find board/st_nucleo_f3.cfg]
proc modm_program { SOURCE } {
	program $SOURCE verify
	reset halt
	mww 0xE000EDF0 0xA05F0000
	shutdown
}

proc program_release {} {
	modm_program build/release/src.elf
}
proc program_debug {} {
	modm_program build/debug/src.elf
}

External projects fail to find modm repository (and docs are lacking)

I have a newbie question, which I could not resolve through docs.

Consider the following directory structure:

$ tree -L 2
.
├── modm
│   ├── AUTHORS
│   ├── ....
│   └── tools
├── modm_example
│   ├── main.cpp
│   └── project.xml
└── modm_stm_example
    ├── blinky.cpp
    └── project.xml

modm_example/project.xml:

<library>
  <extends>modm:board:arduino-uno</extends>
  <options>
     <option name="modm:build:build.path">build</option>
  </options>
  <modules>
    <module>modm:platform:adc</module>
    <module>modm:build:scons</module>
  </modules>
</library>

I have my project modm_example not in modm repo. How can I build it?

I tried two methods:

  1. W/o options
$ cd modm_example
$ lbuild build
[ERROR] lbuild.parser: 
ConfigNode(filename='project.xml')

ERROR: No repositories loaded!
  1. Using -r option:
$ cd modm_example
$ lbuild -r ../modm/repo.lb build
ERROR: Repository name 'modm' is ambiguous. Name must be unique.

For now I'm using the second method. here is the diff:

diff --git a/src/modm/board/arduino_uno/board.xml b/src/modm/board/arduino_uno/board.xml
index 0272933af..ec3c4a03e 100644
--- a/src/modm/board/arduino_uno/board.xml
+++ b/src/modm/board/arduino_uno/board.xml
@@ -1,13 +1,9 @@
 <library>
-  <repositories>
-    <repository>
-      <path>../../../../repo.lb</path>
-    </repository>
-  </repositories>
-
   <options>
     <option name="modm:target">atmega328p</option>
     <option name="modm:platform:clock:f_cpu">16000000</option>
+    <option name="modm:build:avrdude.programmer">arduino</option>
+    <option name="modm:build:avrdude.baudrate">115200</option>
   </options>
   <modules>
     <module>modm:board:arduino-uno</module>

I had the same error with Blue Pill (<extends>modm:board:blue-pill</extends>)

Support for chinese STM32F103C8T6 clones

Hi!
We were unlucky to buy a bunch of BluePills with chinese clone of STM32 called CKS32F103C8T6. As far as I understand, it is a perfect replacement, but openocd fails to upload a firmware in it. If I understand correctly, it is not perfectly compatible - openocd recieves the same CPUTAPID as STM32F3x series MCUs. If I put

set CPUTAPID 0x2ba01477

just before include of mcu's config (so it cannot be fixed by using a custom script), it uploads just fine and works.
It requires futher testing.
I want to propose a change to add an option to bluepill bdf's to support it.

STM32 L4: Side-effect on enableExternalInterrupt

I am witnessing an unexpected behaviour with enableExternalInterrupt.

Enabling external interrupts for GpioInputC8, GpioInputC6 and GpioInputC5 works fine. When enabling the GpioInputB5::enableExternalInterrupt();, the interrupt for a pin change on GpioInputC5 is not triggered anymore.

Board is STM32 Nucleo L476RG.

Oh, this indicated a fundamental misunderstanding of the EXTI in STM32 on my side. With this method only a single pin can be matched to an interrupt line. As GpioInputC5 and GpioInputB5 share the same line, they cannot be enabled at the same time.

Driver for I2C port multiplexer TCA9548A

@salkinium Yes, a nightmare for our beloved I2C bus.

There is a switch TCA9548A suitable and made for multiplexing I2C.

I am implementing a driver for this, and I would like to discuss what the best approach is to integrate this into the I2C infrastructure in modm?
The best would be totally transparent to the user, just accessing up to eight independent I2C bus masters, e.g.

using I2cMasterMultiplexer = modm::tca9548a<modm::platform::I2cMaster2>;
modm::Vl53l0< I2CMasterMultiplexer[0] > distance0(data0);
modm::Vl53l0< I2CMasterMultiplexer[1] > distance1(data1);
...

Any suggestions?

std::chrono literals with periodic timers

It would be nice to do something like this:

#include <modm/board.hpp>
#include <modm/debug/logger.hpp>
#include <modm/processing/timer.hpp>
#include <chrono>
using namespace modm::literals;
using namespace std::literals::chrono_literals;

int
main(){
    auto messageTimer = modm::ShortPeriodicTimer{10ms};
    while(True){
        if(messageTimer.execute()){
            // do stuff
        }
    }
}

Is it possible?

For now I'm using

template<typename timestamp_t= modm::ShortTimestamp, typename...T>
constexpr timestamp_t d2t(std::chrono::duration<T...> c){
    return {
        static_cast<typename timestamp_t::Type>(
                    std::chrono::milliseconds(c).count())};
}

Problems using lbuild with windows

Hi all,

I'm trying to use modm under windows 10 with anaconda3 64bit. I've followed the steps in the installation page and found a few mistakes.

  • "conda install" command from anaconda can't install github recipes like "pip install" can

  • pyelftools is not available from conda-forge thus I had to install it using pip

In order to solve this issues I used the following commands to procede with the installation:

conda create --name modm python=3 pip #this is needed because otherwise anaconda will use the global pip and not the one from the env
activate modm
conda install -c conda-forge git 
pip install jinja2 scons future pyelftools git+https://github.com/modm-io/library-builder

After doing this I had to configure a .bat file to run the lbuild file inside Scripts, something simple like this:

@echo off
set scriptname=%~dp0%~n0
python "%scriptname%" %*

After doing this I cloned recursively the repository and I could call lbuild inside an example directory, but I got this error:

c:\modm\examples\stm32f4_discovery\blink (develop)
(modm3) λ lbuild -v build
[INFO] lbuild.module: Found module 'cmsis'
[INFO] lbuild.module: Found module 'core'
[INFO] lbuild.module: Found module 'dsp'
[INFO] lbuild.module: Found module 'fatfs'
[INFO] lbuild.module: Found module 'freertos'
[INFO] lbuild.module: Found module 'device'
[INFO] lbuild.module: Found module 'ros'
[INFO] lbuild.module: Found module 'device'
[INFO] lbuild.module: Found module 'tlsf'
[INFO] lbuild.module: Found module 'architecture'
[INFO] lbuild.module: Found module 'accessor'
[INFO] lbuild.module: Found module 'adc'
[INFO] lbuild.module: Found module 'assert'
[INFO] lbuild.module: Found module 'atomic'
[INFO] lbuild.module: Found module 'block.device'
[INFO] lbuild.module: Found module 'can'
[INFO] lbuild.module: Found module 'clock'
[INFO] lbuild.module: Found module 'delay'
[INFO] lbuild.module: Found module 'gpio'
[INFO] lbuild.module: Found module 'gpio.expander'
[INFO] lbuild.module: Found module 'heap'
[INFO] lbuild.module: Found module 'i2c'
[INFO] lbuild.module: Found module 'i2c.device'
[INFO] lbuild.module: Found module 'interrupt'
[INFO] lbuild.module: Found module 'memory'
[INFO] lbuild.module: Found module '1-wire'
[INFO] lbuild.module: Found module 'register'
[INFO] lbuild.module: Found module 'spi'
[INFO] lbuild.module: Found module 'spi.device'
[INFO] lbuild.module: Found module 'uart'
[INFO] lbuild.module: Found module 'unaligned'
[INFO] lbuild.module: Found module 'board'
[INFO] lbuild.module: Found module 'al-avreb-can'
[INFO] lbuild.module: Found module 'arduino-uno'
[INFO] lbuild.module: Found module 'black-pill'
[INFO] lbuild.module: Found module 'blue-pill'
[INFO] lbuild.module: Found module 'disco-f051r8'
[INFO] lbuild.module: Found module 'disco-f072rb'
[INFO] lbuild.module: Found module 'disco-f100rb'
[INFO] lbuild.module: Found module 'disco-f303vc'
[INFO] lbuild.module: Found module 'disco-f407vg'
[INFO] lbuild.module: Found module 'disco-f429zi'
[INFO] lbuild.module: Found module 'disco-f469ni'
[INFO] lbuild.module: Found module 'disco-f746ng'
[INFO] lbuild.module: Found module 'disco-f769ni'
[INFO] lbuild.module: Found module 'disco-l476vg'
[INFO] lbuild.module: Found module 'nucleo-f031k6'
[INFO] lbuild.module: Found module 'nucleo-f042k6'
[INFO] lbuild.module: Found module 'nucleo-f103rb'
[INFO] lbuild.module: Found module 'nucleo-f303k8'
[INFO] lbuild.module: Found module 'nucleo-f401re'
[INFO] lbuild.module: Found module 'nucleo-f411re'
[INFO] lbuild.module: Found module 'nucleo-f429zi'
[INFO] lbuild.module: Found module 'nucleo-l432kc'
[INFO] lbuild.module: Found module 'nucleo-l476rg'
[INFO] lbuild.module: Found module 'olimexino-stm32'
[INFO] lbuild.module: Found module 'stm32f030_demo'
[INFO] lbuild.module: Found module 'communication'
[INFO] lbuild.module: Found module 'ros'
[INFO] lbuild.module: Found module 'sab'
[INFO] lbuild.module: Found module 'sab2'
[INFO] lbuild.module: Found module 'xpcc'
[INFO] lbuild.module: Found module 'container'
[INFO] lbuild.module: Found module 'debug'
[INFO] lbuild.module: Found module 'driver'
[INFO] lbuild.module: Found module 'ad7280a'
[INFO] lbuild.module: Found module 'ad7928'
[INFO] lbuild.module: Found module 'adc_sampler'
[INFO] lbuild.module: Found module 'memory_bus'
[INFO] lbuild.module: Found module 'lawicel'
[INFO] lbuild.module: Found module 'mcp2515'
[INFO] lbuild.module: Found module 'tcs3414'
[INFO] lbuild.module: Found module 'tcs3472'
[INFO] lbuild.module: Found module 'ea_dog'
[INFO] lbuild.module: Found module 'hd44780'
[INFO] lbuild.module: Found module 'max7219'
[INFO] lbuild.module: Found module 'nokia5110'
[INFO] lbuild.module: Found module 'parallel_tft_display'
[INFO] lbuild.module: Found module 'sdl_display'
[INFO] lbuild.module: Found module 'siemens_s65'
[INFO] lbuild.module: Found module 'siemens_s75'
[INFO] lbuild.module: Found module 'ssd1306'
[INFO] lbuild.module: Found module 'mcp23x17'
[INFO] lbuild.module: Found module 'pca8574'
[INFO] lbuild.module: Found module 'pca9535'
[INFO] lbuild.module: Found module 'hmc58x'
[INFO] lbuild.module: Found module 'hmc6343'
[INFO] lbuild.module: Found module 'itg3200'
[INFO] lbuild.module: Found module 'l3gd20'
[INFO] lbuild.module: Found module 'lis302dl'
[INFO] lbuild.module: Found module 'lis3dsh'
[INFO] lbuild.module: Found module 'lis3.transport'
[INFO] lbuild.module: Found module 'lsm303a'
[INFO] lbuild.module: Found module 'adns9800'
[INFO] lbuild.module: Found module 'drv832x_spi'
[INFO] lbuild.module: Found module 'vl53l0'
[INFO] lbuild.module: Found module 'vl6180'
[INFO] lbuild.module: Found module 'amsys5915'
[INFO] lbuild.module: Found module 'bme280'
[INFO] lbuild.module: Found module 'bmp085'
[INFO] lbuild.module: Found module 'hclax'
[INFO] lbuild.module: Found module 'max6966'
[INFO] lbuild.module: Found module 'pca9685'
[INFO] lbuild.module: Found module 'nrf24'
[INFO] lbuild.module: Found module 'ds1302'
[INFO] lbuild.module: Found module 'block.device'
[INFO] lbuild.module: Found module 'file'
[INFO] lbuild.module: Found module 'heap'
[INFO] lbuild.module: Found module 'mirror'
[INFO] lbuild.module: Found module 'spi.flash'
[INFO] lbuild.module: Found module 'fat'
[INFO] lbuild.module: Found module 'i2c.eeprom'
[INFO] lbuild.module: Found module 'ds1631'
[INFO] lbuild.module: Found module 'ds18b20'
[INFO] lbuild.module: Found module 'lm75'
[INFO] lbuild.module: Found module 'ltc2984'
[INFO] lbuild.module: Found module 'tmp102'
[INFO] lbuild.module: Found module 'tmp175'
[INFO] lbuild.module: Found module 'ads7843'
[INFO] lbuild.module: Found module 'ft6x06'
[INFO] lbuild.module: Found module 'ft245'
[INFO] lbuild.module: Found module 'io'
[INFO] lbuild.module: Found module 'math'
[INFO] lbuild.module: Found module 'matrix'
[INFO] lbuild.module: Found module 'filter'
[INFO] lbuild.module: Found module 'geometry'
[INFO] lbuild.module: Found module 'interpolation'
[INFO] lbuild.module: Found module 'saturated'
[INFO] lbuild.module: Found module 'utils'
[INFO] lbuild.module: Found module 'platform'
[INFO] lbuild.module: Found module 'adc'
[INFO] lbuild.module: Found module 'adc'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module '3'
[INFO] lbuild.module: Found module 'adc'
[INFO] lbuild.module: Found module 'canusb'
[INFO] lbuild.module: Found module 'can.common'
[INFO] lbuild.module: Found module 'can'
[INFO] lbuild.module: Found module 'socketcan'
[INFO] lbuild.module: Found module 'can'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module 'clock'
[INFO] lbuild.module: Found module 'clock.cortex'
[INFO] lbuild.module: Found module 'clock'
[INFO] lbuild.module: Found module 'clock'
[INFO] lbuild.module: Found module 'comp'
[INFO] lbuild.module: Found module 'core'
[INFO] lbuild.module: Found module 'core'
[INFO] lbuild.module: Found module 'core'
[INFO] lbuild.module: Found module 'dma'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module 'fault.cortex'
[INFO] lbuild.module: Found module 'fsmc'
[INFO] lbuild.module: Found module 'gpio'
[INFO] lbuild.module: Found module 'gpio.common'
[INFO] lbuild.module: Found module 'gpio'
[INFO] lbuild.module: Found module 'gpio'
[INFO] lbuild.module: Found module 'gpio'
[INFO] lbuild.module: Found module 'i2c'
[INFO] lbuild.module: Found module 'i2c.bitbang'
[INFO] lbuild.module: Found module 'i2c'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module '3'
[INFO] lbuild.module: Found module 'i2c'
[INFO] lbuild.module: Found module 'i2c'
[INFO] lbuild.module: Found module 'id'
[INFO] lbuild.module: Found module '1-wire.bitbang'
[INFO] lbuild.module: Found module 'random'
[INFO] lbuild.module: Found module 'spi'
[INFO] lbuild.module: Found module 'spi_uart'
[INFO] lbuild.module: Found module 'spi.bitbang'
[INFO] lbuild.module: Found module 'spi'
[INFO] lbuild.module: Found module 'spi'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module '3'
[INFO] lbuild.module: Found module 'uart.spi'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module '3'
[INFO] lbuild.module: Found module '6'
[INFO] lbuild.module: Found module 'spi'
[INFO] lbuild.module: Found module 'timer'
[INFO] lbuild.module: Found module 'timer'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '8'
[INFO] lbuild.module: Found module '6'
[INFO] lbuild.module: Found module '7'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module '3'
[INFO] lbuild.module: Found module '4'
[INFO] lbuild.module: Found module '5'
[INFO] lbuild.module: Found module '9'
[INFO] lbuild.module: Found module '10'
[INFO] lbuild.module: Found module '11'
[INFO] lbuild.module: Found module '12'
[INFO] lbuild.module: Found module '13'
[INFO] lbuild.module: Found module '14'
[INFO] lbuild.module: Found module 'timer'
[INFO] lbuild.module: Found module 'uart'
[INFO] lbuild.module: Found module 'uart'
[INFO] lbuild.module: Found module 'uart'
[INFO] lbuild.module: Found module 'uart'
[INFO] lbuild.module: Found module '4'
[INFO] lbuild.module: Found module '5'
[INFO] lbuild.module: Found module '1'
[INFO] lbuild.module: Found module '2'
[INFO] lbuild.module: Found module '3'
[INFO] lbuild.module: Found module '6'
[INFO] lbuild.module: Found module 'uart'
[INFO] lbuild.module: Found module 'processing'
[INFO] lbuild.module: Found module 'protothread'
[INFO] lbuild.module: Found module 'resumable'
[INFO] lbuild.module: Found module 'rtos'
[INFO] lbuild.module: Found module 'scheduler'
[INFO] lbuild.module: Found module 'timer'
[INFO] lbuild.module: Found module 'button'
[INFO] lbuild.module: Found module 'color'
[INFO] lbuild.module: Found module 'ui'
[INFO] lbuild.module: Found module 'animation'
[INFO] lbuild.module: Found module 'display'
[INFO] lbuild.module: Found module 'gui'
[INFO] lbuild.module: Found module 'led'
[INFO] lbuild.module: Found module 'menu'
[INFO] lbuild.module: Found module 'time'
[INFO] lbuild.module: Found module 'utils'
[INFO] lbuild.module: Found module 'stdc++'
[INFO] lbuild.module: Found module 'unittest'
[INFO] lbuild.module: Found module 'test'
[INFO] lbuild.module: Found module 'architecture'
[INFO] lbuild.module: Found module 'communication'
[INFO] lbuild.module: Found module 'container'
[INFO] lbuild.module: Found module 'driver'
[INFO] lbuild.module: Found module 'io'
[INFO] lbuild.module: Found module 'math'
[INFO] lbuild.module: Found module 'platform'
[INFO] lbuild.module: Found module 'gpio'
[INFO] lbuild.module: Found module 'spi'
[INFO] lbuild.module: Found module 'processing'
[INFO] lbuild.module: Found module 'ui'
[INFO] lbuild.module: Found module 'stdc++'
[INFO] lbuild.module: Found module 'build'
[INFO] lbuild.module: Found module 'cmake'
[INFO] lbuild.module: Found module 'scons'
[INFO] lbuild.module: Found module 'docs'
[INFO] lbuild.module: Found module 'generator'

[INFO] lbuild.parser: Selected modules: modm:board:disco-f407vg, modm:build:scons
[INFO] lbuild.module: Prepare for build modm:platform:gpio
[INFO] lbuild.module: Prepare for build modm:cmsis:device
[INFO] lbuild.module: Build modm:platform:spi:1

ERROR: Failed to retrieve Template: src\modm\platform\spi\stm32\spi_hal.hpp.in

The file spi_hal.hpp.in is in my directory structure and I can't understand what's the problem,
I tryed running again the lbuild build command and it got stuck at this point this time:

ERROR: Failed to retrieve Template: src\modm\platform\i2c\stm32\i2c_master.cpp.in

This is my python environment and python version:

c:\modm\examples\stm32f4_discovery\blink (develop)
(modm3) λ pip list
Package Version


certifi 2018.8.13
future 0.16.0
gitdb2 2.0.4
GitPython 2.1.11
Jinja2 2.10
lbuild 0.1
lxml 4.2.4
MarkupSafe 1.0
pip 18.0
pyelftools 0.24
scons 3.0.1
setuptools 40.0.0
smmap2 2.0.4
wheel 0.31.1
wincertstore 0.2

c:\modm\examples\stm32f4_discovery\blink (develop)
(modm3) λ python
Python 3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 11:48:23) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

I hope this will help getting a better windows support.

Reproducible library generation

I'd like to check in the generated library to my project to freeze the state and reduce external utility dependencies on building the project.
Of course, the library configuration shall be part of the repository and can be regenerated at any time.

I noticed that a second run of lbuild build does not generate the identical library.

diff --git a/src/modm/src/modm/platform/gpio/gpio_A0.hpp b/src/modm/src/modm/platform/gpio/gpio_A0.hpp
index 18035a0..1591a88 100644
--- a/src/modm/src/modm/platform/gpio/gpio_A0.hpp
+++ b/src/modm/src/modm/platform/gpio/gpio_A0.hpp
@@ -223,10 +223,11 @@ public:
                        "GpioA0::Ch1 only connects to Tim2!");
        };
        template< Peripheral peripheral >
-       struct Etr { static void connect();
+       struct In0 { static void connect();
                static_assert(
-                       (peripheral == Peripheral::Tim2),
-                       "GpioA0::Etr only connects to Tim2!");
+                       (peripheral == Peripheral::Adc1) ||
+                       (peripheral == Peripheral::Adc2),
+                       "GpioA0::In0 only connects to Adc1 or Adc2!");
        };
        template< Peripheral peripheral >
        struct Wkup { static void connect();
@@ -235,11 +236,10 @@ public:
                        "GpioA0::Wkup only connects to Sys!");
        };
        template< Peripheral peripheral >
-       struct In0 { static void connect();
+       struct Etr { static void connect();
                static_assert(
-                       (peripheral == Peripheral::Adc1) ||
-                       (peripheral == Peripheral::Adc2),
-                       "GpioA0::In0 only connects to Adc1 or Adc2!");
+                       (peripheral == Peripheral::Tim2),
+                       "GpioA0::Etr only connects to Tim2!");
        };
 };

This makes it difficult to track changes in the generated code.

Would it be possible to make sure the output is reproducible, e.g. by sorting items alphabetically?

XMega support

In an effort to learn lbuild, scons, etc I thought i would compile a project for my older boards. They are all XMega based. I noticed xmega was not in the filter list in repo.lb so I added it and ran into the following errors:

  • spi/uart module instances are named with letters according the port they are on
  • adc/dac signals are names with digits
  • counters also have letters, c0, c1, d0, d1 ...

the line in the spi (line 68) and uart (line 91) module:
module.add_submodule(Instance(int(instance)))
fails since the instance is named 'c' and 'd' on my atxmega128a4u

if I remove the int cast it progresses but fails with the message in the gpio module :

ERROR: These signal names are starting with a digit!
AcA::0, AcA::1, AcA::2, AcA::3, AcA::4, AcA::5, AcA::6, AcA::7, DacB::0, DacB::1

Snippet of the relevant XML from the device file:

      <gpio port="B" pin="0">
        <signal driver="ac" instance="b" name="0"/>
        <signal device-name="64" driver="adc" instance="a" name="7"/>
        <signal device-name="128" driver="adc" instance="a" name="8"/>
        <signal driver="adc" instance="a" name="refb0"/>
        <signal driver="adc" instance="b" name="0"/>
        <signal driver="adc" instance="b" name="refb0"/>
      </gpio>
    <driver name="spi" type="avr">
      <instance value="c"/>
      <instance value="d"/>
    </driver>
    <driver name="tc" type="tc">
      <instance value="c0"/>
      <instance value="c1"/>
      <instance value="d0"/>
      <instance value="d1"/>
      <instance value="e0"/>
      <instance device-pin="" value="exc"/>
      <instance device-pin="" value="resc"/>
      <instance device-pin="" value="resd"/>
      <instance device-pin="" value="rese"/>
    </driver>
    <driver name="twi" type="avr">
      <instance value="c"/>
      <instance value="e"/>
    </driver>
    <driver name="usart" type="avr">
      <instance value="c0"/>
      <instance value="c1"/>
      <instance value="d0"/>
      <instance value="d1"/>
      <instance value="e0"/>
    </driver>

LPC memory layout / Shared RAM with on-chip API

In

https://github.com/modm-io/modm/blob/develop/tools/devices/lpc/lpc11c24.xml#L18

<driver name="core" type="cortex">
      <memory name="sram1" access="rwx" start="0x10000100" size="8"/>

the start of the RAM was assigned to to 0x1000 0100 with a size of 8 KiBytes.

Accordingly to Figure 6 in UM10398.pdf, RAM starts at 0x1000 0000

image

Additionally, accordingly to section 17.4.1 ("Calling the C_CAN API"), "On-chip RAM from address 0x1000 0050 to 0x1000 00B8 is used by the CAN API.":

image

This might be the reason why the first used RAM was moved to 0x1000 0100 in xpcc back then.

I just want to clarify this to do the right things in the future. We probably need a feature in modm to reserve some RAM block for the use of on-chip peripherals / API code?!

Use C++17 language features

We're already using C++14 by default, which requires at least GCC 5.
This is an issue for the official avr-gcc from Atmel which ships with Ubuntu in version 4.9.3.
Most other linux distributions, as well as macOS via Homebrew (Q: what about Windows?) compile their own avr-gcc from upstream, which is missing support for several AVR architectures and devices.
For the sake of moving forwards, we've accepted this caveat and are using a self-compiled avr-gcc 7.3.0 for our CI.
ARM already ships arm-none-eabi-gcc for v7.2.0 since the 2017q4 release.

The C++ standards support page for GCC shows that all language features of C++17 (except fixes to template argument deduction for class templates) are supported by GCC 7.
I would therefore like to enable C++17 as the default for modm to already make use of very useful new features such as constexpr if, enhancements to variadic templates, selection statements with initializers, constexpr lambdas and many more.

cc @dergraaf @strongly-typed @rleh @chris-durand @daniel-k @ekiwi @georgi-g @mhthies

Using I2C on Nucleo F303K8

Hi,

I am trying to use I2C on the Nucleo F303K8. I would like to run the ssd1306 example from the stm32f4_discovery display examples.

I am still using I2C1 but instead of GPIOB9 and GPIOB8 I am using GPIOB7 and GPIOB6. I have copied the code (main.cpp and modules from project.xml) over to the blink example of the Nucleo F303K8. The problem is that it does not recognizes I2cMaster1 when compiling. I have tried adding ":platform:i2c:1" as a parameter of module.depends function call inside the Nucleo's module.lb but this leads to a dependency resolution error.

Could you help me on this matter?

Thank you

Support for a CAN send buffer with priorities

While reading through CAN driver's docs (a very lack thereof) and it's source code, I was wondering.
Is there a way to prioritize messages by their ID's with CAN::sendMessage()?
Should such prioritization happen?

Suppose, a device on CAN bus has two (or more) tasks. Each task send a heartbeat message with different ID (and therefore - priority) using CAN::sendMessage(). Suppose also this bus is a very busy one - with lots of other devices sending messages with higher (or equal) priority, than the highest priority of all taks on this device.
Example: Two tasks, sending (1) Msg(pr:0x10, len:8) (2) Msg(pr:0x20, len:1):
Task (2) occures more frequent, but has a lower priority.
Task (1) occures less frequent, but has a higher priority.

Msg(pr:0x20, len:1)
Msg(pr:0x20, len:1)
Msg(pr:0x20, len:1)
Msg(pr:0x20, len:1)
Msg(pr:0x20, len:1)
Msg(pr:0x20, len:1)
Msg(pr:0x10, len:8)
Msg(pr:0x10, len:8)
Msg(pr:0x20, len:1)
Msg(pr:0x20, len:1)
Msg(pr:0x20, len:1)

Is there a way to ensure that task (1) will always get it's message transmitted on time?

support L443CCT6

I would like to have L443CCT6 supprted.
Maybe I can help ... but need some assitance where to start.

Checking out project

Hey! I was just checking this repo out, apparently a lot of the links in the readme seem down, would love to read the API documentation etc. Seems like nice work!

AVR unittests not in best shape

Some AVR unittests are failing, which is troubling.
I'm executing these tests on a AT90CAN128, with 4kB RAM.
The tests have to be split up into several chunks or they won't fit into the Flash.
This can be done simply by including just a few modules instead of all.

Unfortunately, the unittests for Resumables cause a Stack Overflow, which resets the DUT and therefore loops forever. Manually removing a handful of test cases that cause this, shows no tests failed in the resumable however. I'll try this again on a ATmega2560 with 8kB RAM.

These are the failed test cases:

FAIL: slave_test:117 : 0 == 1
FAIL: slave_test:139 : 0 == 2
FAIL: slave_test:147 : true == false
FAIL: slave_test:150 : 1 == 2
FAIL: slave_test:154 :
[1, 163]
[205, 171]
FAIL: slave_test:165 : 0 == 3
FAIL: slave_test:189 : 0 == 4
FAIL: slave_test:190 : 0 == 39030
FAIL: slave_test:198 : true == false
FAIL: slave_test:201 : 1 == 4
FAIL: slave_test:204 :
[1, 9, 0, 222]
[120, 86, 52, 18]
FAIL: bme280_test:208 : true == false
FAIL: bme280_test:209 : true == false
FAIL: bme280_test:289 : true == false
FAIL: bme280_test:290 : true == false
FAIL: bme280_test:208 : true == false
FAIL: bme280_test:209 : true == false
FAIL: bme280_test:289 : true == false
FAIL: bme280_test:290 : true == false
FAIL: ltc2984_test:25 : true == false
FAIL: ltc2984_test:26 : true == false
FAIL: ltc2984_test:98 : 1048576 == 0
FAIL: angle_test:40 : -3.14159e+00 == 3.14159e+00
FAIL: time_test:33 : 1017971200 == 1000000000
FAIL: time_test:52 : 1073676288 == 1073741824
FAIL: time_test:71 : 1322192521 == 1311738121
FAIL: time_test:89 : 1337044484 == 1333329284
FAIL: time_test:108 : 3152047053 == 3141592653
FAIL: time_test:123 : 16 == 9
FAIL: time_test:124 : 5 == 8
FAIL: time_test:157 : 24 == 27
FAIL: time_test:158 : 4 == 6
FAIL: time_test:174 : 9 == 2
FAIL: time_test:175 : 2 == 3
FAIL: time_test:192 : 18 == 21
FAIL: time_test:193 : 4 == 6

36 test failed

:modm:docs is broken on Windows

This first traceback happens when trying to read {modm-repo}/tools/build_script_generator/module.md

Traceback (most recent call last):
  File "C:\Users\fb39ca4\git\stm32f446-can-test\modm-repo\tools\doc_generator\module.lb", line 166, in post_build
    title, descr = split_description(m._description)
  File "C:\Users\fb39ca4\git\stm32f446-can-test\modm-repo\tools\doc_generator\module.lb", line 127, in split_description
    lines = str(descr).strip(" \n").splitlines() + [""]
  File "C:\Users\fb39ca4\AppData\Local\Programs\Python\Python37\lib\site-packages\lbuild\node.py", line 75, in __str__
    return self.read()
  File "C:\Users\fb39ca4\AppData\Local\Programs\Python\Python37\lib\site-packages\lbuild\node.py", line 78, in read
    return file.read()
  File "C:\Users\fb39ca4\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 3281: character maps to <undefined>

This traceback happens when trying to write {output}/docs/dox/modm-build.dox

Traceback (most recent call last):
  File "C:\Users\fb39ca4\git\stm32f446-can-test\modm-repo\tools\doc_generator\module.lb", line 196, in post_build
    env.template("group.dox.in", "{}.dox".format(url_name(m["name"])), filters={"doxify": doxify})
  File "C:\Users\fb39ca4\AppData\Local\Programs\Python\Python37\lib\site-packages\lbuild\facade.py", line 178, in template
    self._env.template(src, dest, substitutions, filters)
  File "C:\Users\fb39ca4\AppData\Local\Programs\Python\Python37\lib\site-packages\lbuild\environment.py", line 323, in template
    outfile.write(output)
  File "C:\Users\fb39ca4\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u250c' in position 3129: character maps to <undefined>

Adding encoding="utf-8" to the open calls in node.py and environment.py just before the exception happens makes the problem go away, but I'm not sure if you want to fix it on lbuild or modm's side.

Also, it would be nice for lbuild to better print stack traces, since by default they only show the most recent call with no further context. I had to insert some try-catch blocks in the code and print stack traces myself, but I will bring up that issue in the lbuild repo.

Support for stm32duino bootloader or linking to different flash address

In order to use the stm32duino bootloader on a blue pill/black pill board it is required to link the user code to 0x08002000 instead of 0x0800000 (default flash location). Using the currently available lbuild options this seems not to be possible without using a custom linkerscript (which I would like to avoid).

Is this a broad enough use case to merit an additional option to add an offset or a custom flash location for linking?

lbuild generates bad scons files on WIndows

On windows, lbuild build generates modm/Sconscript with wrong file separators like this:

....
files = [
    env.File("src\modm\architecture\driver\atomic\flag.cpp"),
    env.File("src\modm\architecture\interface\can.cpp"),
    env.File("src\modm\architecture\interface\can_message.cpp"),
    env.File("src\modm\board\board.cpp"),
....

For now, I cope with this using sed and replacing all \ with / after lbuild build.
After that modm/Sconscript is usable, but I get the same error when trying to run scons program, but worse - as it is passing file name and it gets garbled - instead of build/release/some_name.elf I get buildeleaseomename.elf. It isn't fixable via same method.
Although, using openocd -f modm/openocd.cfg -c program_release works after replacing all \\ in openocd.cfg with /

hd44780 initialization fails because of writeHighNibble(uint8_t) call with RW set to RW::read

I tried to use a 16x2 a HD44780 display with modm/driver/display/hd44780.hpp in 4-bit mode and it would only display garbage after a call to initialize(). It seems that the problem was that, during the inititalize() method, isBusy() would indirectly call RW::set(RW_Read) and, afterwards, a call to Bus<DATA, E, DATA::width>::writeHighNibble(Set4BitBus) would behave unexpectedly, since it requires RW set to RW_Write.

It is implemented in modm/driver/display/hd44780_base_impl.hpp

UART on ATmega8

I'm trying to write a program for an ATmega8 that needs UART.

Based on the AVR examples I put together this project.xml:

<library>
  <options>
    <option name="modm:target">atmega8</option>
    <option name="modm:platform:clock:f_cpu">8000000</option>
    <option name="modm:io:with_printf">True</option>
    <option name="modm:build:avrdude.programmer">avrisp2</option>
  </options>
  <modules>
    <module>modm:architecture:interrupt</module>
    <module>modm:driver:mcp2515</module>
    <module>modm:platform:clock</module>
    <module>modm:platform:core</module>
    <module>modm:platform:gpio</module>
    <module>modm:platform:spi</module>
    <module>modm:platform:uart:0</module>
    <module>modm:processing:timer</module>
    <module>modm:build:scons</module>
  </modules>
</library>

When I run lbuild -r ..\modm\repo.lb build I get this output:

Recomputing device cache...

ERROR: Cannot resolve 'modm:platform:uart:0'

I tried replacing modm:platform:uart:0 with modm:platform:uart, modm:platform:uart:1, but nothing seems to work. Does this mean that the UART is not supported on the mega8 yet?

Executing lbuild build after 8708f3dc

I am facing some trouble with the latest changes introduced by 8708f3d,
when executing lbuild build.

That occurs with various modm examples.

Is it a Python3.5/3.6 issue?

  File "/home/user/.local/lib/python3.5/site-packages/lbuild/parser.py", line 110, in parse_repository
    repo = repository.Repository.parse_repository(repofilename)
  File "/home/user/.local/lib/python3.5/site-packages/lbuild/repository.py", line 64, in parse_repository
    repo._functions['init'](RepositoryInitFacade(repo))
  File "[..]/modm/repo.lb", line 164, in init
    name = re.search("<module>(modm:board:.*?)</module>", config.read_text())[1].replace("modm:", "")
TypeError: '_sre.SRE_Match' object is not subscriptable

Support separate compile flags per module/file in CMake

Some external code may not adhere to the modm coding standards and may generate warnings which may lead to errors due to our general compile flags. This is especially annoying when the external source code cannot be edited due to loosing upstream compatiblity or violating licencing terms.

It would be useful to compile parts of modm and other repositories with different compile flags.
This needs to be done carefully, since some flags are required for the platform (like flags.archflags) and must be used for all files (even in other repositories) and some flags may even contain conflicting definitions for separate files (like flags.cppdefines).
It is unclear how to define the semantics for choosing what build flags to use for user code, since currently all files in SCons's scope are build with the union of all repos/modules of all compile flags.

This will require a new feature in lbuild, for defining metadata per file too, not just per module.

Update 2019-01-16

SCons support has been implemented in #129.
However CMake support is lacking!

No module named 'modm.parser'

lbuild build
No module named 'modm.parser' 

You might be missing the git submodules in `ext/`.
Try:
    cd modm
    git submodule update --init
then build again.

GpioInput and GpioOutput is aliased to Gpio

In AVRs and STMs
both GpioOutput and GpioInput are aliased to Gpio:

class Gpio{{ port ~ pin }};
using GpioOutput{{ port ~ pin }} = Gpio{{ port ~ pin }};
using GpioInput{{ port ~ pin }}  = Gpio{{ port ~ pin }};

I thought that it was a distinct feature of modm that once a pin was declared as as GpioInput it was not able to accidentally use the setOutput method on this pin.

Assume the case that a sinking/sourcing output of another device is directly connected to the pin of the microcontroller. To avoid hardware damage (short circuit), the pin is only used as GpioInput (e.g. by a board support package). Unintentionally setOutput et cetera were avoided at compile time.

Of course, on a micrcontroller without MMU, anybody could do anything at anytime, but I always liked checks in the code which hindered me to do stupid things.

Is it worth considering splitting GpioInput and GpioOutput again in separate classes and letting Gpio the only?

No timers and PWM functions for AVR

References #23.

What are the steps towards enabling support for AVR timers?
Is it manageable to add support for timers to a small handful of devices (like mega328p, mega32u4, mega2560)?

UART 9 data bit mode on AVR

I'm developing a project for AVR where I need to use UART with 9 data bits. The current interface doesn't seem to support this. Do you think it would be reasonable (and not very complicated) to add support in modm for this, or should I just hack together something? :D

(I'm interfacing with SeaTalk, where the 9th data bit is used as the "command bit". Also, as this is a bus protocol, the RX receives what's sent on TX, and actually has to check whether the sent frame is correct before moving on, for collision detection. I think this makes me unable to use the buffered UART functions, so it might make more sense to actually just copy the modm UART code and modify it for myself. Any thoughts?)

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.