Top Banner
Real practice of Networking design on specialized for ARM Cortex-M Ben Wei (a.k.a ben6) 2013/08/03
43

Real practice of Networking design on specialized for ARM Cortex-M

Jun 10, 2015

Download

Technology

Benux Wei

slide for COSCUP 2013
PS: The source of this practice will be released later on github and have an issue which SPI unable to start successfully now.
prototype temporary source code with F4OS and sdp_tcp: https://github.com/benwei/F4OS/tree/feature/coscup2013-stm32-net
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Real practice of Networking design on specialized for ARM Cortex-M

Real practice of Networking

design on specialized for

ARM Cortex-M

Ben Wei (a.k.a ben6) 2013/08/03

Page 2: Real practice of Networking design on specialized for ARM Cortex-M

Right’s to copy

Attribution – ShareAlike 3.0

You are free •  to copy, distribute, display, and perform the work •  to make derivative works

•  to make commercial use of the work Under the following conditions

•  For any reuse or distribution, you must make clear to others the license terms of this work. •  Any of these conditions can be waived if you get permission from the copyright holder.

Your fair use and other rights are in no way affected by the above.

Attribution. You must give the original author credit.

Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.

© Copyright 2013 juluos http://juluos.org

License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode

Page 3: Real practice of Networking design on specialized for ARM Cortex-M

Who am I?

•  Current

o  JuluOSDev, StarOS Lab

•  Bio

Love to try new technologies and

enjoy researching topics in networking

and operation system domains

http://about.me/ben6

Page 4: Real practice of Networking design on specialized for ARM Cortex-M

Agenda

• Why real practice topic?

• Hardware Overview

• Development experience sharing

Page 5: Real practice of Networking design on specialized for ARM Cortex-M

Why? Connect Internet of Things

Internet of Things

Page 6: Real practice of Networking design on specialized for ARM Cortex-M

thingsquare

Page 7: Real practice of Networking design on specialized for ARM Cortex-M

thingsquare

Page 8: Real practice of Networking design on specialized for ARM Cortex-M

thingsquare

Page 9: Real practice of Networking design on specialized for ARM Cortex-M

thingsquare

Page 10: Real practice of Networking design on specialized for ARM Cortex-M

Thingsqure Tech Overview

Thingsqure of Services

Things

Contiki-OS Router

Page 11: Real practice of Networking design on specialized for ARM Cortex-M

Connect Apps with things

Connecting thermostats, light bulbs, street lights, and more

Page 12: Real practice of Networking design on specialized for ARM Cortex-M

Real Practice

Prototype Cortex-M Hardware with Ethernet adapter

Page 13: Real practice of Networking design on specialized for ARM Cortex-M
Page 14: Real practice of Networking design on specialized for ARM Cortex-M

enc28J60 STM32F407VGT6

USB-Serial Controller Prolific 2303

Page 15: Real practice of Networking design on specialized for ARM Cortex-M

STM32F407VGT6

•  32-bit ARM® Cortex™-M4-based STM32-F4

•  168MHz, upto 210 MIPS •  1MB Flash, 192KB RAM

ST-LINK

USB for Input

USB 2.0 OTG

Page 16: Real practice of Networking design on specialized for ARM Cortex-M

Architecture diagram

Network Adapter

Driver

TCPIP Stack (UIP, lwIP, SDP …)

Application 1 Application 2 Application n

Firmware

Hardware

ARM Board

Page 17: Real practice of Networking design on specialized for ARM Cortex-M

Ethernet Adapter

Page 18: Real practice of Networking design on specialized for ARM Cortex-M

Adapter Survery

SPI Ethernet Adapter

Page 19: Real practice of Networking design on specialized for ARM Cortex-M

SPI Interface

SPI Master

SCLK MOSI MISO CS

SPI Slave

SCLK MOSI MISO CS

Serial Peripheral Interface Bus,SPI

Page 20: Real practice of Networking design on specialized for ARM Cortex-M

What’s SPI? (Input)

MSB (I) LSB (I)

Open

Page 21: Real practice of Networking design on specialized for ARM Cortex-M

What’s SPI? (Output)

MSB LSB

ignore

Page 22: Real practice of Networking design on specialized for ARM Cortex-M

Driver – enc28j60

Base on SPI Command with OP Code SPI Commands: RCR, RBM, WCR, WBM, BFS, BFC, SC

Op Code argument data

Byte 0 Byte 1

Page 23: Real practice of Networking design on specialized for ARM Cortex-M

enc28j60 Ethernet adapter

SPI pinout PA5 = SCK PA6 = MISO PA7 = MOSI PE7 = CS

Page 24: Real practice of Networking design on specialized for ARM Cortex-M

ENC28J60 Pinouts

Buffer

Page 25: Real practice of Networking design on specialized for ARM Cortex-M

Development Experience Sharing

Page 26: Real practice of Networking design on specialized for ARM Cortex-M

F4OS

Page 27: Real practice of Networking design on specialized for ARM Cortex-M

F4OS

git://github.com/benwei/F4OS.git -- Fork from prattmic/F4OS

Page 28: Real practice of Networking design on specialized for ARM Cortex-M

F4OS

Page 29: Real practice of Networking design on specialized for ARM Cortex-M

Architecture diagram

Network Adapter

En28j60 Driver

TCPIP Stack (SDP)

Shell

F4OS

Hardware

ARM Board

Simple Server

Page 30: Real practice of Networking design on specialized for ARM Cortex-M

Toolchain

launchpad.net/gcc-arm-embedded/+download

Page 31: Real practice of Networking design on specialized for ARM Cortex-M

Debugging

•  USB Serial Controller •  STM32 STlink

Page 32: Real practice of Networking design on specialized for ARM Cortex-M

USB Serial Console Mac OS X as example

1

Screen is your good friend

sudo screen /dev/tty.usbserial 115200

2

Page 33: Real practice of Networking design on specialized for ARM Cortex-M

st-util wait gdb ben@xubuntu:~/src/github/stlink$ ./st-util 2012-06-10T22:56:32 INFO src/stlink-usb.c: -- exit_dfu_mode 2012-06-10T22:56:32 INFO src/stlink-common.c: Loading device parameters.... 2012-06-10T22:56:32 INFO src/stlink-common.c: Device connected is: F4

device, id 0x20006411 2012-06-10T22:56:32 INFO src/stlink-common.c: SRAM size: 0x30000 bytes

(192 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes Chip ID is 00000413, Core ID is 2ba01477. KARL - should read back as 0x03, not 60 02 00 00 init watchpoints Listening at *:4242...

Listening at *:4242

./st-util

Page 34: Real practice of Networking design on specialized for ARM Cortex-M

gdb with st-util ~/F4OS$ arm-none-eabi-gdb GNU gdb (Sourcery CodeBench Lite 2012.03-56) 7.2.50.20100908-cvs Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-

eabi". For bug reporting instructions, please see: <https://support.codesourcery.com/GNUToolchain/>. (gdb) target remote :4242 Remote debugging using :4242 0x007f3ff4 in ?? ()

target remote :4242

Page 35: Real practice of Networking design on specialized for ARM Cortex-M

How to build F4OS?

$ git://github.com/benwei/F4OS.git $ cd F4OS_prototype $ make clean $ make $ make burn

GCC_ARM_PATH="/opt/gcc-arm-none-eabi-4_7-2013q1/bin" STLINK_PATH="$SH_PATH/stlink” export PATH="$PATH:$GCC_ARM_PATH:$STLINK_PATH"

1

2

Page 36: Real practice of Networking design on specialized for ARM Cortex-M

Write bin file to F4 $ make burn st-flash write ./out/f4os.bin 0x8000000 2013-08-01T13:28:57 INFO src/stlink-common.c: Loading device parameters.... 2013-08-01T13:28:57 INFO src/stlink-common.c: Device connected is: F4 device, id 0x20006411 2013-08-01T13:28:57 INFO src/stlink-common.c: SRAM size: 0x30000 bytes (192 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes 2013-08-01T13:28:57 INFO src/stlink-common.c: Attempting to write 30540 (0x774c) bytes to stm32 address: 134217728 (0x8000000) EraseFlash - Sector:0x0 Size:0x4000 Flash page at addr: 0x08000000 erasedEraseFlash - Sector:0x1 Size:0x4000 Flash page at addr: 0x08004000 erased 2013-08-01T13:28:57 INFO src/stlink-common.c: Finished erasing 2 pages of 16384 (0x4000) bytes 2013-08-01T13:28:57 INFO src/stlink-common.c: Starting Flash write for F2/F4 2013-08-01T13:28:57 INFO src/stlink-common.c: Successfully loaded flash loader in sram size: 30540 2013-08-01T13:28:58 INFO src/stlink-common.c: Starting verification of write complete 2013-08-01T13:28:58 INFO src/stlink-common.c: Flash written and verified! jolly good!

st-flash write ./out/f4os.bin 0x8000000

Page 37: Real practice of Networking design on specialized for ARM Cortex-M

Demo

Environment Demo

Page 38: Real practice of Networking design on specialized for ARM Cortex-M

Summary

•  Why Stm32 Networking?

•  Hardware Prototype: o  STM32F4 Discovery + ENC28J60 + PL2303

•  Experience Sharing & Development tips o  How to build, burn, debug tools

Page 39: Real practice of Networking design on specialized for ARM Cortex-M

? Q & A

Page 40: Real practice of Networking design on specialized for ARM Cortex-M

compile stlink in ubuntu

sudo apt-get install autoconf libusb-1.0.0 sh autogen.sh ./configure make

Tips: please don't install, just use export PATH=~/stlink/:$PATH For easier update

Page 41: Real practice of Networking design on specialized for ARM Cortex-M

STM32F407VGT6 •  microcontroller featuring 32-bit ARM Cortex-M4F core, 1 MB Flash, 192

KB RAM in an LQFP100 package •  On-board ST-LINK/V2 with selection mode switch to use the kit as a

standalone ST- LINK/V2 (with SWD connector for programming and debugging)

•  LIS302DL, ST MEMS motion sensor, 3-axis •  digital output accelerometer •  MP45DT02, ST MEMS audio sensor, omni- directional digital microphone •  CS43L22, audio DAC with integrated class D speaker driver •  Eight LEDs: •  USB OTG FS with micro-AB connector •  Extension header for all LQFP100 I/Os for quick connection to prototyping

board and easy probing

More - reference DM00037955.pdf

Page 42: Real practice of Networking design on specialized for ARM Cortex-M

References

•  ENC28J60 programming guide •  http://thingsquare.com/tech/ •  http://www.contiki-os.org/ •  STM32F4DISCOVERYDiscovery kit

Page 43: Real practice of Networking design on specialized for ARM Cortex-M

CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h

STM32F4 Working MHz (F4OS)

#define PLL_M 25

#define PLL_M 8

-DHSE_VALUE=8000000

boot/boot_main.c

1

2