Cov txheej txheem:

Programming Arduino Over the Air (OTA) - Ameba Arduino: 4 Kauj Ruam
Programming Arduino Over the Air (OTA) - Ameba Arduino: 4 Kauj Ruam

Video: Programming Arduino Over the Air (OTA) - Ameba Arduino: 4 Kauj Ruam

Video: Programming Arduino Over the Air (OTA) - Ameba Arduino: 4 Kauj Ruam
Video: Telnet объяснил 2024, Kaum ib hlis
Anonim
Programming Arduino Over the Air (OTA) - Ameba Arduino
Programming Arduino Over the Air (OTA) - Ameba Arduino

Muaj ntau qhov Wi-nkaus microcontroller tawm muaj nyob hauv khw, ntau tus neeg tsim khoom txaus siab rau kev tsim lawv li Wi-nkaus microcontroller siv Arduino IDE. Txawm li cas los xij, ib qho ntawm qhov zoo tshaj plaws uas Wi-Fi microcontroller yuav tsum tau muab yuav raug saib tsis taus, uas yog lub phiaj xwm thiab xa koj cov cai nyob deb thiab siv tsis tau siv OTA (Over-The-Air) ua haujlwm.

Hauv Cov Lus Qhia no, Kuv yuav qhia koj yuav teeb tsa OTA ntawm koj li Wi-Fi microcontroller siv ubiquitous Arduino IDE ntawm Ameba Arduino Wi-Fi microcontroller li cas!

Khoom siv

Ameba Arduino x 1

Kauj ruam 1: OTA

OTA
OTA

OTA (Over-The-Air) hais txog kev hloov kho online hauv Internet.

Arduino IDE muaj qhov tshwj xeeb OTA, uas ua raws cov haujlwm hauv daim duab saum toj no.

(i) Arduino IDE tshawb nrhiav ntawm mDNS rau cov khoom siv nrog Arduino IDEOTA kev pabcuam hauv zej zog hauv zej zog.

(ii) Txij li thaum kev pabcuam mDNS tau ua haujlwm ntawm Ameba, Ameba teb rau mDNS tshawb nrhiav thiab qhib qhov tshwj xeeb TCP chaw nres nkoj rau kev txuas.

(iii) Tus neeg siv txhim kho txoj haujlwm hauv Arduino IDE. Thaum ua tiav, xaiv network chaw nres nkoj.

(iv) Nyem upload. Tom qab ntawd Arduino IDE xa cov duab OTA mus rau Ameba los ntawm TCP, Ameba khaws cov duab rau qhov chaw nyob tshwj xeeb thiab teeb tsa kev xaiv khau raj los ntawm cov duab no lub sijhawm tom ntej.

Txoj haujlwm ua haujlwm muaj peb ntu: mDNS, TCP thiab OTA txheej txheem duab. Cov ntsiab lus ntsig txog mDNS tau piav qhia hauv mDNS qhia. Lub khoos phis tawj TCP tau siv los hloov cov duab thiab twb tau muab hauv OTA API.

Hauv ntu tom ntej, peb yuav tham txog yuav ua li cas txheej txheem OTA duab, thiab qhia qee qhov kev paub yooj yim ntawm Ameba flash nco kev teeb tsa thiab khau raj ntws.

Kauj Ruam 2: Ameba Flash Memory Layout

Ameba Flash Memory Layout
Ameba Flash Memory Layout

Lub cim xeeb nco me me ntawm Ameba RTL8195A yog 2MB, thaj tsam ntawm 0x00000000 txog 0x00200000. Txawm li cas los xij, lub cim xeeb nco loj ntawm Ameba RTL8710 yog 1MB. Kom haum rau kev siv cov laug cam sib txawv, peb xav tias qhov teeb tsa flash nco yog 1MB.

Raws li tau qhia hauv daim duab saum toj no, Ameba program nyob peb ntu ntawm lub cim xeeb nco:

- Boot Duab :

Ntawd yog, bootloader. Thaum Ameba khau looj plab hlaub, nws tso lub khau raj duab rau nco thiab ua qhov pib. Tsis tas li ntawd, nws txiav txim siab yuav mus qhov twg tom qab bootloader. Bootloader saib ntawm OTA chaw nyob thiab tus pin rov qab hauv cov kab ke cov ntaub ntawv thiab txiav txim siab tias daim duab twg yuav ua tom qab. Thaum kawg ntawm lub bootloader, nws tso cov duab rau cim xeeb thiab muaj txiaj ntsig los ua nws.

- Default Duab 2 :

Tus lej tsim tawm tau muab tso rau hauv ntu no, qhov chaw nyob pib los ntawm 0x0000B000. Thawj 16 bytes yog cov duab header, 0x0000B008 ~ 0x0000B00F suav nrog Kos Npe, uas yog siv los txheeb xyuas seb daim duab puas siv tau. Qhov chaw kos npe muaj ob qhov txiaj ntsig siv tau los cais qhov duab tshiab los ntawm daim duab qub.

- OTA Duab :

Cov ntaub ntawv hauv ntu no tseem yog tus tsim tawm txoj cai. Los ntawm lub neej ntawd, ib feem ntawm kev nco pib los ntawm 0x00080000 (tuaj yeem hloov pauv). Qhov sib txawv tseem ceeb ntawm OTA duab thiab Default Image 2 yog qhov chaw nco flash thiab Tus nqi kos npe.

Sib nrug los ntawm cov cai, muaj qee cov ntaub ntawv thaiv:

- Cov ntaub ntawv kaw lus System

Cov ntaub ntawv kaw lus pib los ntawm 0x00009000. Muaj ob qho ntaub ntawv ntsig txog OTA:

1. OTA chaw nyob: 4 bytes cov ntaub ntawv pib los ntawm 0x00009000. Nws qhia OTA Duab chaw nyob. Yog tias OTA qhov chaw nyob tsis raug (piv txwv li, 0xFFFFFFFF), OTA duab hauv flash nco tsis tuaj yeem thauj khoom kom raug.

2. Rov Qab Pin : 4 bytes cov ntaub ntawv pib los ntawm 0x00009008, Tus pin rov qab yog siv los txiav txim siab tias daim duab twg (lub neej ntawd Duab 2 lossis OTA Duab) kom ua tiav thaum ob daim duab siv tau. Yog tias tus lej tus lej rov qab tsis raug (piv txwv li, 0xFFFFFFFF), daim duab tshiab yuav ua tiav los ntawm lub neej ntawd.

Cov ntaub ntawv kaw lus yuav raug tshem tawm thaum peb tso cov program rau Ameba ntawm DAP. Ntawd yog, qhov chaw nyob OTA yuav raug tshem tawm thiab Ameba yuav txiav txim siab tias tsis muaj duab OTA.

- Cov Ntaub Ntawv Calibration : Cov ntaub ntawv ntsuas ntsuas ib puag ncig tau muab tso rau hauv qhov thaiv no. Feem ntau cov ntaub ntawv no yuav tsum tsis txhob muab tshem tawm.

Kauj ruam 3: Boot Flow

Boot Flow
Boot Flow

Los ntawm daim duab saum toj no, Peb tham txog cov xwm txheej hauv qab no: (i) OTA tsis raug siv, siv DAP txhawm rau rub cov program:

Hauv qhov xwm txheej no, bootloader tshawb xyuas qhov kos npe ntawm cov duab tsis raug 2 thiab OTA chaw nyob. Txij li qhov chaw nyob OTA raug tshem tawm, cov duab tsis zoo 2 yuav raug xaiv los ua.

(ii) OTA duab tau hloov mus rau Ameba, OTA chaw nyob tau teeb tsa kom raug, tus pin rov qab tsis tau teeb tsa.

Ameba tau txais cov duab hloov tshiab ntawm OTA, kos npe ntawm daim duab tsis zoo 2 yuav raug teeb tsa rau kos npe qub.

Bootloader tshuaj xyuas qhov kos npe ntawm cov duab qub 2 thiab OTA chaw nyob. Nws yuav pom OTA chaw nyob muaj cov duab OTA siv tau. Txij li tus pin rov qab tsis tau teeb tsa, nws xaiv cov duab tshiab (piv txwv li, OTA duab) kom ua tiav.

(iii) OTA duab raug xa mus rau Ameba, OTA chaw nyob tau teeb tsa kom raug, tus pin rov qab tau teeb tsa.

Ameba tau txais cov duab hloov tshiab ntawm OTA, kos npe ntawm daim duab tsis raug 2 yuav raug teeb tsa rau qub kos npe.

Bootloader tshuaj xyuas qhov kos npe ntawm cov duab qub 2 thiab OTA chaw nyob. Nws yuav pom OTA chaw nyob muaj cov duab OTA siv tau. Tom qab ntawd txheeb xyuas tus lej tus lej rov qab. Yog tias tus pin rov qab txuas nrog LOW, daim duab tshiab (piv txwv li, OTA duab) yuav ua tiav. Yog tias tus pin rov qab txuas nrog HIGH, cov duab qub (piv txwv li, lub neej ntawd duab 2) yuav ua tiav.

Kauj ruam 4: Piv txwv

Piv txwv
Piv txwv
Piv txwv
Piv txwv
Piv txwv
Piv txwv
Piv txwv
Piv txwv

Txhawm rau siv OTA qhov tshwj xeeb, thov hloov kho DAP firmware rau version> 0.7 (v0.7 tsis suav nrog). Lub Hoobkas default DAP firmware yog version 0.7. Thov ua raws cov lus qhia txhawm rau txhim kho DAP firmware:

Qhib qhov piv txwv: "File" -> "Piv txwv" -> "AmebaOTA" -> "ota_basic"

Sau rau hauv ssid thiab tus lej xov tooj cov ntaub ntawv hauv tus qauv piv txwv rau kev sib txuas network.

Muaj qee qhov tsis cuam tshuam nrog OTA:

§ MY_VERSION_NUMBER : Hauv thawj version, peb yuav tsum teeb tsa OTA chaw nyob thiab tus pin rov qab. Txij li lub sijhawm no peb tso tawm ntawm USB yog thawj zaug, peb tsis tas yuav hloov tus nqi no.

§ OTA_PORT : Arduino IDE yuav pom Ameba ntawm mDNS. Ameba yuav qhia rau Arduino IDE tias nws qhib TCP chaw nres nkoj 5000 tos rau OTA duab.

§ RECOVERY_PIN ig Kho tus pin siv rau kev rov zoo. Peb siv tus pin 18 ntawm no.

Tom qab ntawd peb siv USB upload program rau Ameba. Nyem Cov Cuab Yeej -> Chaw Nres Nkoj, kos lub chaw nres nkoj txuas mus siv :

Thov nco ntsoov tias Arduino IDE siv ib qho chaw nres nkoj rau upload cov program thiab cov ntawv tso tawm. Txhawm rau zam qhov xwm txheej uas lub cav tsis tuaj yeem tsim tawm thaum peb siv OTA, peb siv lwm qhov chaw nres nkoj chaw nres nkoj (piv txwv li, Tera lub sijhawm lossis muab tso rau) hloov chaw saib xyuas kom saib cov lus sau.

Tom qab ntawd nyem upload thiab nias khawm pib dua.

Hauv cov lus hais txog lub cav:

1. Nruab nrab ntawm “===== Sau Duab 1 ====” thiab “Sau Duab 2 ====”, koj tuaj yeem pom “Flash Image 2: Addr 0xb000”. Qhov no txhais tau tias Ameba txiav txim siab khau raj los ntawm Default Image 2 ntawm 0xb000.

2. Tom qab "Sau Duab 2 ====", koj tuaj yeem pom "Nov yog version 1". Nov yog cov lus qhia peb ntxiv hauv daim duab.

3. Tom qab Ameba txuas nrog AP thiab tau txais IP chaw nyob "192.168.1.238", nws qhib mDNS thiab tos rau cov neeg siv khoom.

Tom ntej no, peb hloov "MY_VERSION_NUMBER" rau 2.

Nyem "Cov Cuab Yeej" -> "Chaw Nres Nkoj", koj tuaj yeem pom cov npe "Network chaw nres nkoj". Nrhiav "MyAmeba ntawm 192.168.1.238 (Ameba RTL8195A)", MyAmeba yog mDNS lub npe ntaus ntawv peb teeb tsa hauv cov qauv qauv, thiab "192.168.1.238" yog IP ntawm Ameba.

Yog tias koj tsis tuaj yeem pom lub networkport ntawm Ameba, thov lees paub:

- Puas yog koj lub khoos phis tawj thiab Ameba nyob hauv tib lub network?

- sim rov pib dua Arduino IDE.

- txheeb xyuas cov lus hauv Serial Monitor kom pom tias Ameba txuas nrog AP ua tiav.

Ces nyem upload. Lub sijhawm no txoj haujlwm yuav raug tshaj tawm ntawm TCP. Hauv lub davhlau ya nyob twg log, koj tuaj yeem pom cov ntaub ntawv sib txuas rau cov neeg siv khoom.

Thaum OTA daim duab tau rub tawm tiav, Ameba yuav rov pib dua thiab ua raws cov cav yuav pom nyob hauv lub davhlau ya nyob twg.

- Nruab nrab “===== Sau Duab 1 ====” thiab “Sau Duab 2 ====”, koj tuaj yeem pom cov lus sau “Flash Image 2: Addr 0x80000”. Qhov no txhais tau tias Ameba txiav txim siab khau raj los ntawm OTA Duab ntawm 0x80000.

- Tom qab "Sau Duab 2 ====", lub cav "Nov yog version 2" yog cov lus peb ntxiv hauv daim duab.

Txhawm rau rov ua dua cov duab yav dhau los tom qab OTA duab rub tawm rau Ameba, thov txuas tus pin rov qab peb teeb tsa hauv daim duab (piv txwv li, tus pin 18) mus rau HIGH (3.3V), thiab nias pib dua.

Tom qab ntawd cov duab Default 2 yuav raug xaiv thaum khau raj. Nco ntsoov tias cov duab OTA rub tawm tsis raug tshem tawm, thaum tus pin rov qab raug txuas los ntawm HIGH, daim duab OTA yuav ua tiav.

Peb suav cov kev txhim kho ntws siv OTA hauv daim duab hauv qab no.

Pom zoo: