sama5d3: how to run linux on it

17
Павел Курочкин General R&D, 2017 Запускаем Linux на sama5d3 “Оживляем” ARM SoC + NAND

Upload: pavel-kurochkin

Post on 28-Jan-2018

101 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Запускаем Linux на sama5d3

“Оживляем” ARM SoC + NAND

Page 2: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

О чём пойдёт речь?

● Минимальная схема● Компоненты загрузки ARM-а● Про NAND и PMECC● Тулчейн, сборка rootfs● Прошивка NAND через USB● Адаптация под плату

2

Page 3: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Минимальная схема

3

SAM a5d3NAND SDRAM

UART/DBGU

USB

Page 4: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

SAM a5d3

● Atmel, теперь Microchip● Up to 536 MHz● Cortex-A5, ARMv7 hard float● Gigabit Ethernet, USB, UARTs, I2C, etc…● NAND, SD, etc..● TRNG, Encryption Engine

4

Page 5: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Процесс загрузки

1. Boot rom2. bootstrap/preloader -- up to 128K3. u-boot4. Linux kernel + rootfs

Храним на NAND’е

5

Page 6: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

NAND + PMECC

● 4016 из 4096 без ошибок● 2048B + 64B OOB для ECC● Корр. 4 байта из 2048● Конфигурируется при

прошивке NAND

6

Корр. биты ECC байты для блока 512 байт

2 4

4 7

8 13

12 20

24 39

Page 7: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Тулчейн

● Debian 8● gcc-gnueabi-armhf-gcc тулчейн из репозитория

EmDebian● Make● Linaro toolchain тоже подходит

7

Page 8: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

rootfs

● Debian 8● qemu-debootstrap для сборки rootfs● mkfs.ubifs + ubinize для сборки ubi-образа

8

Page 9: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

sam-ba: прошивка NAND (GUI)

● USB● Sam-ba 2.13● Помним про PMECC

● at91bootstrap.bin● at91-sama5d3.dtb● u-boot.bin● zImage● rootfs

9

Page 10: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

sam-ba: прошивка NAND (CLI)

● https://github.com/linux4sam/meta-atmel● Shell + tcl● ~ 1 MB/s

10

Page 11: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Адаптируем под плату: bootstrap

● Настройка памяти● Внутренний/внешний RC-осциллятор● PMECC● Тип загрузки: сразу ядро или u-boot● C● https://github.com/linux4sam/at91bootstrap

11

Page 12: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Адаптируем под плату: u-boot

● Выбираем нужную периферию● PMECC● Адреса dtb, zImage● Адрес u-boot environment’а● Параметры загрузки ядра● C● https://github.com/linux4sam/u-boot-at91

12

Page 13: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Адаптируем под плату: kernel

● PMECC● dts/dtb: за основу берём sama5d3-xplained● Включаем поддержку UBI● Стартовый config: sama5-defconfig● https://github.com/linux4sam/linux-at91

13

Page 14: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

U-boot enviroment...

bootargs=console=ttyS0,115200n8 earlyprintk

mtdparts=atmel_nand:256k(bs)ro,512k(uboot)ro,256k(env),256k(env1),

256k(spare),512k(dtb),6M(kernel)ro,-(rootfs) rootfstype=ubifs

ubi.mtd=7 root=ubi0:rootfs rw

bootcmd=nand read 0x21000000 0x180000 0x80000;nand read 0x22000000

0x200000 0x600000;bootz 0x22000000 - 0x21000000

...

14

Page 15: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Грабли

● Trimffs при прошивке ubi rootfs● Внутренний/внешний осциллятор● systemd

15

Page 16: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Итого

● Минималистичное окружение (debian forever)○ apt-get install binfmt-support qemu qemu-user-static mtd-utils

debootstrap○ apt-get install crossbuild-essential-armhf○ apt-get install mtd-tools

● sam-ba для прошивки● PMECC для NAND

16

Page 17: Sama5d3: how to run linux on it

Павел Курочкин General R&D, 2017

Ссылки

● https://github.com/linux4sam/at91bootstrap● https://github.com/linux4sam/u-boot-at91● https://github.com/linux4sam/linux-at91● http://www.at91.com/linux4sam/bin/view/Linux4SAM/

17