Slide 1

Slide 1 text

Go to Songdo 2023 TinyGo for Maker 박제창 (Dreamwalker) / GDG Golang Korea TinyGo를 위한 여정 Go to Songdo 2023

Slide 2

Slide 2 text

Go to Songdo 2023 • 박제창 @Dreamwalker • Dreamus Company • GDG Golang Korea • Flutter Seoul • Github: JAICHANGPARK Speaker

Slide 3

Slide 3 text

Go to Songdo 2023

Slide 4

Slide 4 text

Go to Songdo 2023 Index ● MicroController ● Language & IDE ● Build, Compile, Flash ⚡ ● TinyGo ● TinyGo Led Blink ● TinyGo I2C

Slide 5

Slide 5 text

Go to Songdo 2023 Are you maker?

Slide 6

Slide 6 text

Go to Songdo 2023 Are you maker Programming 회로설계 PCB (Artwork) 등등 Hardware Software MCU 인두기 장비들 3D 프린터 각종 공구 등등 다재다능해야함.

Slide 7

Slide 7 text

Go to Songdo 2023 Microcontroller AVR

Slide 8

Slide 8 text

Go to Songdo 2023 Micro-controller (MCU)

Slide 9

Slide 9 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● 도체: 전류가 잘 통하는 물질 ○ 금, 은 ○ 구리 ● 부도체: 전류가 통하지 않는 물질 ○ 고무 ○ 기름 ○ 유리 ○ 플라스틱 ● 반도체: 도체와 부도체 그 사이

Slide 10

Slide 10 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) Mass 9.10×10^−31 kg

Slide 11

Slide 11 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU)

Slide 12

Slide 12 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● 옥텟 규칙(octet rule)을 기억하시나요? https://www.shindengen.com/products/semi/coumn/basic/semi/semi_basic.html https://www.newtondesk.com/silicon-element/ https://en.wikipedia.org/wiki/Silicon

Slide 13

Slide 13 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) 퀴즈 실리콘은 주로 무엇으로 만들어질까요?

Slide 14

Slide 14 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) https://en.wikipedia.org/wiki/Desert

Slide 15

Slide 15 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● 도핑 (Doping) ○ N형 ■ 실리콘에 Donor를 Doping 하면 생성되는 반도체 ■ 최외각 전자가 5개인 원소를 주입 ○ P형 ■ 실리콘(규소)에 acceptor를 Doping하면 생성되는 반도체 ■ 최외각 전자가 3개인 원소를 주입

Slide 16

Slide 16 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● Diode

Slide 17

Slide 17 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● Diode (Light-emitting diode) https://en.wikipedia.org/wiki/Shuji_Nakamura

Slide 18

Slide 18 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● 진공관

Slide 19

Slide 19 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● Transistor https://en.wikipedia.org/wiki/Transistor ● 증폭기 ● 스위치(칭)

Slide 20

Slide 20 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● 논리회로 ● Half ● Full adder

Slide 21

Slide 21 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● 논리회로 ● CMOS Based ● Full Adder https://en.wikipedia.org/wiki/Adder_(electronics)

Slide 22

Slide 22 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● 54 시리즈 ● 74 시리즈 ● TTL ● 74LS ● 74HC ● 등등 ● 7408 (AND GATE) ● 7404 ● 7432 ● 등등

Slide 23

Slide 23 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● https://en.wikipedia.org/wiki/Intel_8080

Slide 24

Slide 24 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) https://fr.wikipedia.org/wik i/Zilog_Z80 1976 Transistors : 8,500 4마이크로공정

Slide 25

Slide 25 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) Apple M2 2022 : 20,000,000,000 (200억개) Z80 1970s 8,500개

Slide 26

Slide 26 text

Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) ● FPGA https://en.wikipedia.org/wiki/Field-pr ogrammable_gate_array ● VHDL ● Verilog

Slide 27

Slide 27 text

Go to Songdo 2023 Micro-controller (MCU)

Slide 28

Slide 28 text

Go to Songdo 2023 Micro-controller (MCU)

Slide 29

Slide 29 text

Go to Songdo 2023 Micro-controller (MCU)

Slide 30

Slide 30 text

Go to Songdo 2023 Micro-controller (MCU) https://docs.arduino.cc/learn/programming/memory-guide

Slide 31

Slide 31 text

Go to Songdo 2023 Micro-controller (MCU) https://www.addicore.com/ATtiny85-p/ad303.htm

Slide 32

Slide 32 text

Go to Songdo 2023 Micro-controller (MCU)

Slide 33

Slide 33 text

Go to Songdo 2023 Micro-controller (MCU) Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz NXP i.MX 8M SoC (quad Cortex-A53, Cortex-M4F)

Slide 34

Slide 34 text

Go to Songdo 2023 Micro-controller (MCU) Cortex-M0+ processor with 264kB internal RAM and support for up to 16MB of off-chip flash

Slide 35

Slide 35 text

Go to Songdo 2023 Micro-controller (MCU)

Slide 36

Slide 36 text

Go to Songdo 2023 Micro-controller (MCU) 제가 최근 수년간 애용하는.. ESP32 시리즈 32bit Wi-Fi BLE, Bluetooth ZigBee

Slide 37

Slide 37 text

Go to Songdo 2023 Micro-controller (MCU) 개발하려는 시스템 필요한 포트 수 (=핀 수) Peripherals 메모리 전원, 시스템 전류 소모 전력 동작 주파수 등등 Complex

Slide 38

Slide 38 text

Go to Songdo 2023 Language & IDE

Slide 39

Slide 39 text

Go to Songdo 2023 Language 주로 사용하는 언어 C/C++ assembly 익숙하신가요?

Slide 40

Slide 40 text

Go to Songdo 2023 General? IDE https://www.st.com/en/partner-products-and-services/ arm-keil-mdk.html

Slide 41

Slide 41 text

Go to Songdo 2023 General? IDE https://www.iar.com/

Slide 42

Slide 42 text

Go to Songdo 2023 General? IDE https://www.st.com/en/development -tools/stm32cubeide.html

Slide 43

Slide 43 text

Go to Songdo 2023 General? IDE https://os.mbed.com/

Slide 44

Slide 44 text

Go to Songdo 2023 Arduino IDE

Slide 45

Slide 45 text

Go to Songdo 2023 Arduino IDE

Slide 46

Slide 46 text

Go to Songdo 2023 Arduino IDE

Slide 47

Slide 47 text

Go to Songdo 2023 Build(Compile) Flash

Slide 48

Slide 48 text

Go to Songdo 2023 Build, Compile 스케치는 프로그램 저장 공간 235905 바이트(17%)를 사용. 최대 1310720 바이트. 전역 변수는 동적 메모리 22056바이트(6%)를 사용, 305624바이트의 지역변수가 남음. 최대는 327680 바이트.

Slide 49

Slide 49 text

Go to Songdo 2023 Flash 굽다

Slide 50

Slide 50 text

Go to Songdo 2023 TinyGo?

Slide 51

Slide 51 text

Go to Songdo 2023 TinyGo https://tinygo.org/

Slide 52

Slide 52 text

Go to Songdo 2023 TinyGo PlayGround https://play.tinygo.org/

Slide 53

Slide 53 text

Go to Songdo 2023 TinyGo CLI Command build: compile packages and dependencies run: compile and run immediately test: test packages flash: compile and flash to the device gdb: run/flash and immediately enter GDB lldb: run/flash and immediately enter LLDB monitor: open communication port env: list environment variables used during build list: run go list using the TinyGo root clean: empty cache directory (C:\Users\HOME613\AppData\Local\tinygo) targets: list targets info: show info for specified target version: show version help: print this help text

Slide 54

Slide 54 text

Go to Songdo 2023 TinyGo Driver ● 보드에 다양한 센서를 연결하여 사용 ● 일반적으로 센서 제조자에서 드라이버를 제공하기도 함(C/C++코드만) ● 그외 제공되는 라이브러리(드라이버)는 오픈소스 형태 ● TinyGo도 대중적인 센서들을 드라이버가 존재해서 쉽게 사용이 가능

Slide 55

Slide 55 text

Go to Songdo 2023 TinyGo Go compatibility matrix https://tinygo.org/docs/reference/go-compat-matrix/

Slide 56

Slide 56 text

Go to Songdo 2023 TinyGo Install

Slide 57

Slide 57 text

Go to Songdo 2023 Set-ExecutionPolicy RemoteSigned -Scope CurrentUser irm get.scoop.sh | iex TinyGo Install Windows - Scoop

Slide 58

Slide 58 text

Go to Songdo 2023 scoop install tinygo TinyGo Install Windows

Slide 59

Slide 59 text

Go to Songdo 2023 scoop install binaryen TinyGo Install WebAssembly/WASI

Slide 60

Slide 60 text

Go to Songdo 2023 LED BLINK

Slide 61

Slide 61 text

Go to Songdo 2023 TinyGo LED Blink Arduino Nano RP2040 Connect 약 4만원 대

Slide 62

Slide 62 text

Go to Songdo 2023 TinyGo LED Blink Arduino Nano RP2040 Connect Raspberry Pi® RP2040 Nina W102 uBlox module

Slide 63

Slide 63 text

Go to Songdo 2023 TinyGo LED Blink Arduino Nano RP2040 Connect ● Dual Cortex M0+ processor cores, up to 133MHz ● 264kB of embedded SRAM in 6 banks ● 30 multifunction GPIO ● 6 dedicated IO for SPI Flash (supporting XIP) ● Dedicated hardware for commonly used peripherals ● Programmable IO for extended peripheral support ● 4 channel ADC with internal temperature sensor, 500ksps, 12-bit conversion ● USB 1.1 Host/Device

Slide 64

Slide 64 text

Go to Songdo 2023 TinyGo LED Blink Arduino Nano RP2040 Connect TinyGo Support? https://tinygo.org/docs/reference/mi crocontrollers/nano-rp2040/

Slide 65

Slide 65 text

Go to Songdo 2023 #pragma once #include #include #ifndef __PINS_ARDUINO__ #define __PINS_ARDUINO__ #ifdef __cplusplus extern "C" unsigned int PINCOUNT_fn(); #endif #define PIN_LED (13u) #define LED_BUILTIN PIN_LED TinyGo LED Blink https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/NANO_RP2040_CONNECT/pins_arduino.h

Slide 66

Slide 66 text

Go to Songdo 2023 class NinaPin { public: NinaPin(int _pin) : pin(_pin) {}; int get() { return pin; }; int analogReadResolution() { return getAnalogReadResolution(); }; bool operator== (NinaPin const & other) const { return pin == other.pin; } //operator int() = delete; __attribute__ ((error("Change me to a #define"))) operator int(); private: int pin; }; TinyGo LED Blink https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/NANO_RP2040_CONNECT/nina_pins.h

Slide 67

Slide 67 text

Go to Songdo 2023 // Arduino Example C/C++ based void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); } TinyGo LED Blink

Slide 68

Slide 68 text

Go to Songdo 2023 // TinyGo golang based led := machine.LED led.Configure(machine.PinConfig{Mode: machine.PinOutput}) for { led.Low() time.Sleep(time.Millisecond * 500) led.High() time.Sleep(time.Millisecond * 500) } TinyGo LED Blink

Slide 69

Slide 69 text

Go to Songdo 2023 TinyGo LED Blink led.Configure(machine.PinConfig{Mode: machine.PinOutput}) Code Compile LLVM machine code Flash 0x40041000 0xd0000000

Slide 70

Slide 70 text

Go to Songdo 2023 TinyGo LED Blink led.Configure(machine.PinConfig{Mode: machine.PinOutput})

Slide 71

Slide 71 text

Go to Songdo 2023 TinyGo LED Blink led.Low() time.Sleep(time.Millisecond * 500) led.High() time.Sleep(time.Millisecond * 500) power led LED BUILT IN

Slide 72

Slide 72 text

Go to Songdo 2023 TinyGo LED Blink N Mosfet

Slide 73

Slide 73 text

Go to Songdo 2023 I2C Communication

Slide 74

Slide 74 text

Go to Songdo 2023 TinyGo I2C https://www.analog.com/en/technical-articles/i2c-primer-what-is-i2c-part-1.html ● What’s I2C?

Slide 75

Slide 75 text

Go to Songdo 2023 TinyGo I2C https://www.analog.com/en/technical-articles/i2c-primer-what-is-i2c-part-1.html ● What’s I2C?

Slide 76

Slide 76 text

Go to Songdo 2023 TinyGo I2C https://www.analog.com/en/technical-articles/i2c-primer-what-is-i2c-part-1.html 쓰기 읽기 ● What’s I2C?

Slide 77

Slide 77 text

Go to Songdo 2023 TinyGo I2C https://en.wikipedia.org/wiki/I%C2%B2C ● What’s I2C?

Slide 78

Slide 78 text

Go to Songdo 2023 TinyGo I2C MPU6050

Slide 79

Slide 79 text

Go to Songdo 2023 i2c := machine.I2C0 err := i2c.Configure(machine.I2CConfig{ SCL: machine.I2C0_SCL_PIN, SDA: machine.I2C0_SDA_PIN, }) if err != nil { println("could not configure I2C:", err) return } TinyGo I2C

Slide 80

Slide 80 text

Go to Songdo 2023 TinyGo I2C

Slide 81

Slide 81 text

Go to Songdo 2023 w := []byte{0x75} //117 r := make([]byte, 1) err = i2c.Tx(0x68, w, r) if err != nil { println("could not interact with I2C device:", err) return } println("WHO_AM_I:", r[0]) TinyGo I2C

Slide 82

Slide 82 text

Go to Songdo 2023 TinyGo I2C MPU6050

Slide 83

Slide 83 text

Go to Songdo 2023 퀴즈 GopherCon Korea 2023 어디서 열릴까요??

Slide 84

Slide 84 text

Go to Songdo 2023 Thank you