樹莓派 3 三兩事之 UART 落幕篇 ??!!

即將要到『愚人節』了︰

愚人節位於每年公曆4月1日,是從19世紀開始在西方興起流行的民間節日,並未被任何國家認定為法定節日。在這一天人們以各種方式互相欺騙、捉弄及取笑,往往在玩笑的最後才揭穿並宣告捉弄對象為「愚人」。玩笑的性質極少包含實質惡意,但個別玩笑由於開得過大而引起人們的恐慌,產生較大規模反響及衍生成為(傳媒謠言都市傳說,所以對於人們來說一般會加以避免如災難之事的玩笑。

 

作者不知是否樹莓派 3 之『 UART 』,就要如此定案的耶??

Hexxeh/rpi-firmware

kernel: lirc_rpi: Lower IR reception error to debug

See: raspberrypi/linux#1361

kernel: vchiq_arm: Access the dequeue_pending flag locked
See: raspberrypi/linux@a7419d5

kernel: BCM270X_DT: Add pi3-act-led overlay
See: raspberrypi/linux#1363

firmware: sdram: cache the last set_frequency
firmware: pwm_sdm: Set SDRAM turbo frequency to default if pwm_sdm is enabled
See: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=136445

firmware: vchiq_lib: Don't overwrite loop count mid-loop
See: https://discourse.osmc.tv/t/frequent-random-muting-then-freezing/9875/104

# UART 方案
firmware: arm_loader: Change mini-UART initialisation order
See: raspberrypi/firmware#553

 

如果從目前『討論』而言︰

Raspberry Pi 3 model B Serial console does not use correct baudrate #553

Serial console seems to give a incorrect baudrate. Overriding frequencies to previous Raspberries in /boot/config.txt helps: everything works as normal. After some iterations, I found that setting ‘gpu_freq=300’ solves the problem, although that is the default setting on a rpi 3. Probably someone reads that value to initialise the baudrate generator, and uses the old default ‘gpu_freq=250’ if the value is not set. This is almost certainly done in the closed-source /boot/start*.elf files. All those files do contain the texts ‘config.tst’ as well as ‘gpu_freq’. Please repair this issue..

……

  • If the console is on UART1 (mini-UART) – the default case on Pi3 – you get serial output if and only if enable_uart=1. The core frequency is fixed at 250MHz, unless force_turbo=1 in which case it is fixed at 400MHz (provided there is sufficient power and cooling).
  • If the console is on UART0 (PL011) – the default case on Pi0, Pi1, Pi2 and CM – you get serial output unless enable_uart=0. The core frequency is not restricted.

The only implication for Raspbian is that raspi-config should toggle enable_uart when the serial console is configured. It is safe to continue to send output to the UART when it is “disabled” because the UARTs are configured but disconnected from the GPIO pins. From today, a clean Raspbian install that has been rpi-updated will output to the serial port by default unless it is a Pi3, in which it is disabled unless enable_uart is set; it should never output corrupted data (unless you get over-temperature or under-voltage with force_turbo=1).

I’m in favour of making enable_uart=0 the default on all Pis, once people have had time to get used to the idea and we’ve not thought of any gotchas.

……

@pelwell mkknlimg does indeed allow the DT overlay to switch the RPi 3 console UART back to the PL011.

I’ve tested firmware.git commit 046effa “firmware: arm_loader: emmc clock depends on core clock See: #572” and found no blocking issues. From my perspective this bug can be closed, but I’ll leave that up to @josn0 since they filed the bug.

I did find one quirk, but I’m not sure there’s anything that can/should be done about it: On the RPi 3, if config.txt specifies enable_uart=0, or has no enable_uart line at all, then the mini UART is still enabled (so as not to hang SW that transmits data on it). However, the RX pinmux is not set up, so the UART continually receives 0x00 bytes (I didn’t actually verify the value; I assume 0x00). Perhaps the RX pinmux could still be set up to avoid this, leaving enable_uart simply as a flag that the user actively wants to use the UART so clock rates should be fixed? I suppose it’s quite plausible these days that a U-Boot user would only use HDMI+usbkbd, in the same way we assume a user of Linux GUI would.

My test matrix:

RPi B+
HDMI: OK
UART: OK
MMC: OK
Net: OK

RPi 2 B
HDMI: OK
UART: OK
MMC: OK
Net: OK

RPi 3 B 32-bit
MU (rpi_3_32b build):
HDMI: OK
UART: OK
MMC: OK
Net: OK
enable_uart=0 or no enable_uart stanza work: OK, with quirk
PL01x (rpi_2 build w/ DT overlay to switch UARTs):
HDMI: OK
UART: OK
MMC: OK
Net: OK

RPi 3 B 64-bit
MU (rpi_3 build):
HDMI: OK
UART: OK
MMC: OK
Net: OK

───

 

彷彿…的乎!!

 

 

 

 

 

 

 

 

 

 

 

 

 

W!o+ 的《小伶鼬工坊演義》︰樹莓派 3 小樹林系統之展望

即使只是『小樹林系統』,也很難孤立於『世界叢林』之外,所以還是先知道

About Open Connectivity Foundation

Billions of connected devices (devices, phones, computers and sensors) should be able to communicate with one another regardless of manufacturer, operating system, chipset or physical transport. The Open Connectivity Foundation (OCF) is creating a specification and sponsoring an open source project to make this possible. OCF will unlock the massive opportunity in the IoT market, accelerate industry innovation and help developers and companies create solutions that map to a single open specification. OCF will help ensure secure interoperability for consumers, business, and industry.

───

 

是何許組織的好!或可多了解

About

Each day more and more devices are coming online, adding to the ever-growing Internet of Things (IoT). Analysts agree the IoT will grow to many billions of devices over the next decade.

The challenge for the IoT ecosystem is to ensure these emerging IoT devices can connect securely and reliably to the Internet and to each other.

The IoTivity project was created to bring together the open source community to accelerate the development of the framework and services required to connect these billions of devices.

The IoTivity project is sponsored by the Open Interconnect Consortium (OIC), a group of industry leaders who will be developing a standard specification and certification program to address these challenges.

IoTivity will deliver an open source reference implementation of the OIC standard specifications, yet will not be limited to those requirements.

We invite you to explore the site, download the code and start participating today.

───

 

到底在做些什麼?嘗試弄清楚整個架構想法

Architecture Overview

The IoTivity architectural goal is to create a new standard by which billions of wired and wireless devices will connect to each other and to the internet. The goal is an extensible and robust architecture that works for smart and thin devices.

The architecture will provide a roadmap for manufacturers and service providers, including:

Common solution
Define a communication and interoperability solution across multiple product markets such as Consumer, Enterprise, Industrial, Automotive,  and Health, and across operating systems, platforms, communication modes, transports and use cases.

Established protocols
Reuse existing and establish new common communication protocols for discovery and connectivity across multiple transports.

Common approaches
Apply common approaches for security and identity.

Defined commonalities
Define common profiles, object models, and developer application programming interfaces (APIs).

Interoperability
Promote device and application interoperability across markets and use cases.

Innovation opportunities
Provide opportunities for innovation and allow for differentiation.

Necessary connectivity
Connect everything from the smallest wearable to the largest smart car.

IoTivity Architecture

The IoTivity framework APIs expose the framework to developers, and are available in several languages and for multiple operating systems. The APIs are based on a resource-based, RESTful architecture model.

The framework operates as middleware across all operating systems and connectivity platforms and has four essential building blocks:

  1. Discovery
    IoTivity discovery supports multiple discovery mechanisms for devices and resources in proximity and remotely.
  2. Data transmission
    IoTivity data transmission supports information exchange and control based on a messaging and streaming model.
  3. Data Management
    IoTivity data management supports the collection, storage and analysis of data from various resources.
  4. Device management
    IoTivity device management supports configuration, provisioning and diagnostics of devices.

───

 

以為將來預作準備的乎!!也許也該讀讀

Raspberry Pi Going Realtime with RT Preempt

A realtime operating system gives you deterministic latency and jitter with hard bounds on latency and latency variation (jitter). A realtime operating system is an essential prerequisite for implementing so-called Cyber Physical Systems, where a computer controls a physical process. Prominent examples are the control of machines and robots in production environments (the famous Industry 4.0 paradigm), drones, etc.

RT Preempt is a popular patch for the Linux kernel to transform Linux into such a realtime operating system. Moreover, the Raspberry Pi has many nice features to interface with sensors and actuators like SPI, I2C, and GPIO so it seems to be a good platform for hosting a controller in a cyber-physical system. Consequently, it is very attractive to install Linux with the RT Preempt patch on the Raspberry Pi.

Exactly this is what I do here: I provide detailed instructions on how to install a Linux kernel with RT Preempt patch on a Raspberry Pi. Basically, I wrote this document to document the process for myself, and it is more or less a collection of information you will find on the web. But anyway, I hope I can save some people some time.

───

 

也該看看

Xenomai

協作者

  • 2015 年春季
  • 吳哲綱, 曾柏翔, 林展翔, 詹志鴻, 林建慶, 呂鴻, 楊于進
  • 2014 年春季
  • 向澐, 林家宏, 呂科進, 趙愷文, 阮志偉, 陳建霖

Real Time 的定義

一個real time的系統需要保證其工作在給定的時間限制內完成(稱為deadline)。 系統不需要以最快的速度(real fast)完成任務,但需要時常或每次皆在deadline之內完成。

在這個前提下,real time系統的任務完成時間是可確定的(deterministic)。 而根據系統的限制不同,real time可分為:

  • Soft Real Time

系統不一定每次皆需要遵守deadline,但較多的deadline miss會導致服務品質降低。

  • Hard Real Time

系統能每次皆能在deadline內完成任務。

───

 

可能給『小樹林系統』帶來的功效以及用處耶!!

 

 

 

 

 

 

 

 

 

 

 

 

 

W!o+ 的《小伶鼬工坊演義》︰樹莓派 3 小樹林系統之驗證

雖然『小樹林系統』韌體已有新的版本︰

GrovePi/Firmware/Source/v1.2/grove_pi_v1_2_6/grove_pi_v1_2_6.ino

,初步考察

# 主設定
void setup()
{
    // Serial.begin(38400); // start serial for output
    Wire.begin(SLAVE_ADDRESS);
    Wire.onReceive(receiveData);
    Wire.onRequest(sendData);
# 二‧八問題主因,需要 // 
        attachInterrupt(0,readPulseDust,CHANGE);
}

# cmd buffer 仍會越界
void receiveData(int byteCount)
{
    while(Wire.available())
    {
      if(Wire.available()==4)
      {
        flag=0;
        index=0;
               run_once=1;
      }
        cmd[index++] = Wire.read();
    }
}

// callback for sending data
void sendData()
{
  if(cmd[0] == 1)
    Wire.write(val);
  if(cmd[0] == 3 || cmd[0] == 7 || cmd[0] == 56)
    Wire.write(b, 3);
  if(cmd[0] == 8 || cmd[0] == 20)
    Wire.write(b, 4);
  if(cmd[0] == 30)
    Wire.write(b, 9);
  if(cmd[0] == 40)
    Wire.write(dht_b, 9);

  if(cmd[0]==21)
  {
    Wire.write(b,21);
    b[0]=0;
  }
  if(cmd[0]==dust_sensor_read_cmd)
  {
    Wire.write(b,4);
        dust_latest=0;
        cmd[0]=0;
  }
  if(cmd[0]==encoder_read_cmd)
  {
    Wire.write(enc_val,2);
    enc_val[0]=0;
        cmd[0]=0;
  }
  if(cmd[0]==flow_read_cmd)
  {
    Wire.write(flow_val,3);
    flow_val[0]=0;
        cmd[0]=0;
  }
}

 

,看來老問題依舊!!故不急於更新也。

實測驗證結果如下︰

pi@raspberrypi ~ cat /proc/version  Linux version 4.1.20-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #865 SMP Mon Mar 21 18:50:16 GMT 2016 pi@raspberrypi ~

 

pi@raspberrypi ~ ls /dev/i2c* -l crw-rw---- 1 root i2c 89, 1  3月 22 20:22 /dev/i2c-1 crw-rw---- 1 root i2c 89, 3  3月 22 20:22 /dev/i2c-3 pi@raspberrypi ~ 

 

pi@raspberrypi ~ i2cdetect -y 1      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 00:          -- -- 05 -- -- -- -- -- -- -- -- -- --  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  70: -- -- -- -- -- -- -- --                          pi@raspberrypi ~ i2cdetect -y 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- 05 -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@raspberrypi ~ </pre>   <pre class="lang:sh decode:true"># 硬體 I2C pi@raspberrypi ~/example python
Python 2.7.9 (default, Mar  8 2015, 00:52:26) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import grovepi
>>> addr = 0x05
>>> grovepi.debugEnable()
>>> potentiometer = 0
>>> grovepi.pinMode(potentiometer,"INPUT")
1
>>> grovepi.analogRead(potentiometer)
0
[11, 2, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
707
>>> ultrasonic_ranger = 2
>>> grovepi.ultrasonicRead(ultrasonic_ranger)
0
[11, 0, 225, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
225
>>> grovepi.ultrasonicRead(ultrasonic_ranger)
0
[11, 0, 225, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
225
>>> power=7
>>> grovepi.pinMode(power,"OUTPUT")
1
>>> grovepi.digitalWrite(power,1)
1
>>> grovepi.digitalWrite(power,0)
1
>>> grovepi.bus.write_i2c_block_data(5, 1, [3] + [0, 0, 0])
>>> grovepi.bus.read_i2c_block_data(5, 1)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.bus.write_i2c_block_data(5, 1, [3] + [0, 0, 0])
>>> grovepi.read_i2c_byte(addr)
0
>>> grovepi.bus.read_i2c_block_data(5, 1)
[11, 2, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_byte(addr)
0
>>> grovepi.read_i2c_block(addr)
[11, 2, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> 

 

pi@raspberrypi ~ stty -F /dev/ttyUSB0 115200 pi@raspberrypi ~ cat /dev/ttyUSB0 
CMD = 254, index =  4

CMD = 5, index =  4

CMD = 3, index =  4

DATA = 0, 2, 195

CMD = 3, index =  0

CMD = 7, index =  4

DATA = 0, 0, 225

CMD = 7, index =  0

CMD = 7, index =  4

DATA = 0, 0, 225

CMD = 7, index =  0

CMD = 5, index =  4

CMD = 2, index =  4

CMD = 2, index =  4

CMD = 3, index =  4

CMD = 3, index =  0

CMD = 3, index =  4

DATA = 0, 2, 195

CMD = 3, index =  0

DATA = 0, 2, 195

CMD = 1, index =  1

CMD = 1, index =  2

CMD = 1, index =  3

CMD = 1, index =  4

CMD = 1, index =  0


 

想來樹莓派 3 之硬體 I2C 的『□ ○』一點也沒『改變』的耶??

 

※ 上天的使者

Bernhard_Plockhorst_-_Schutzengel

環山該有美,內湖應慈悲。
芳齡止四歲!奈何逐夢歸?

 

 

 

 

 

 

 

 

 

 

 

 

W!o+ 的《小伶鼬工坊演義》︰樹莓派 3 小樹林系統之回歸

總是到了回歸『小樹林系統』的時候了。隨著時間流逝,生怕記憶會褪色,學習會生疏。故於此摘要過往篇章,以為複習也。

W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計《實驗》

……

將要如何追查

若是考以不同『裝置組合』,為什麼『超聲波測距儀』 Ultrasonic Ranger 與『繼電器』 Relay 分接『三、七』可以!但是『二、八』卻不行的呢?

import time
import grovepi

relay = 8

ultrasonic_ranger = 2

grovepi.pinMode(relay,"OUTPUT")

time.sleep(0.1)

grovepi.digitalWrite(relay,1)

time.sleep(0.5)

while True:
    try:

# 因派生二、三『 print 』語法不同之相容寫法。
        print (grovepi.ultrasonicRead(ultrasonic_ranger))

        time.sleep(0.1)

    except IOError:
        print ("Error")

。 一個簡單如此的程式!又怎麼會出錯的呢?既然是寫 W!o+ 的『小伶鼬工坊演義』,總該採納 Mrphs 是怎麼說的哩!!恍恍惚惚中,或是這麼講的吧︰ W!o+ 認為『單獨』與『共聚』物件情況,有很大的不同。縱使彼此可以排除『干擾性』,還有『同時性』和『共時性』的難題,這大部分發生於『資源性』之競奪領域。 若是因『時序性』之問題引起,它在『通訊規範』的設計上尤其重要。大自然春暖花開固然花花無礙,社會上洛陽紙貴可就買不著的了。這些終究還是得用『實驗』 來『確立』的事務。……

───

 

W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧甲

……

之『★★』的『論難』也。所以這裡僅先列出『修改』、『測試』之事,再做『討論』耶??!!

pi@raspberrypi ~/example python Python 2.7.9 (default, Mar  8 2015, 00:52:26)  [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import grovepi >>> addr = 0x05  # 不觸動韌體『 receiveData 』, Wire 傳回 0  >>> grovepi.read_i2c_byte(addr) 0 # 觸動韌體『 receiveData 』, SMBus 讀回 32 byte 。注意第二 Byte 亦為 0 。這或許是 GrovePi 的回傳緩衝器 buffer 始於一之故。 由於會改變 index ,恐有『越界』之虞。 >>> grovepi.read_i2c_block(addr) [11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] # Grove - Rotary Angle Sensor 測試 >>> potentiometer = 0 >>> sensor_value = grovepi.analogRead(potentiometer) 0 [11, 2, 190, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] >>> sensor_value 702 # 注意。注意。這造成 cmd[5] array 指標『越界』。 >>> grovepi.read_i2c_block(addr) [11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] # 無須設定 Grove - Rotary Angle Sensor 為『輸入』? >>> grovepi.pinMode(potentiometer,"INPUT") 1 # Ultrasonic sensor 接於『二』測試。已將//attachInterrupt(0,readPulseDust,CHANGE); 『刪除』。 請注意多次讀取值。 >>> ultrasonic_ranger = 2 >>> grovepi.ultrasonicRead(ultrasonic_ranger) 0 [11, 1, 196, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]  452 # Relay 接於『八』測試 >>> relay = 8 # 一定要宣告 pinMode 為『輸出』 >>> grovepi.pinMode(relay,"OUTPUT") 1 # relay 開 >>> grovepi.digitalWrite(relay,1) 1 # relay 關 >>> grovepi.digitalWrite(relay,0) 1 # 與 relay 沒有交互影響。注意讀取值與之前不同 >>> grovepi.ultrasonicRead(ultrasonic_ranger) 0 [11, 0, 199, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] 199 # 注意指標『越界』 >>> grovepi.read_i2c_block(addr) [11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] # 注意指標『變化』 >>> grovepi.digitalWrite(relay,1) 1 # 穩定性測試 >>> grovepi.analogRead(potentiometer) 0 [11, 2, 190, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]  702 >>>  </pre> ───     <span style="color: #666699;"><a style="color: #666699;" href="http://www.freesandal.org/?p=47815">W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧乙</a></span>  ……  <span style="color: #808000;">既然欲覽 GrovePi 之園林景觀,又已知其韌體</span>  <span style="color: #ff9900;">void receiveData(int byteCount)</span>  <span style="color: #808000;">有『越界』的事實。豈應不先修繕,就隨意斧鑿開墾的耶!因此在繼續探索前, 略作一點『補丁』,同時制定『除錯』啟閉『指令』 ,這也算未來增刪『感測器』時,先將寫程式之章法預演一下。 </span>  <span style="color: #808080;"><strong>【 grove_pi_v1_2_5.ino 補丁】</strong></span> <pre class="lang:default decode:true"># grove_pi_v1_2_5.ino 第三十三行。 int cmd[5]; int index=0; int flag=0; int i; byte val=0,b[21],float_array[4],dht_b[21]; unsigned char dta[21]; int length; int aRead=0; byte accFlag=0,clkFlag=0; int8_t accv[3]; byte rgb[] = { 0, 0, 0 }; int run_once; # 增加 debug int debug = 0;  # 第五百八十九行         else if(cmd[0]==flow_dis_cmd)     {                 flow_run_bk=0;         detachInterrupt(0);         cmd[0]=0;     }  # 增加啟閉指令 # 開啟     else if(cmd[0]==254)       debug=1; # 關閉     else if(cmd[0]==255)       debug=0;   }  # 第六百五十六行        cmd[index++] = Wire.read();     } # 出 while 迴圈後,檢查 index     //cmd buffer index check     if(index==5)       index=0; # 是否要 debug     if(debug==1)     {       Serial.print("CMD = ");       Serial.print(cmd[0]);       Serial.print(", ");       Serial.print("index =  ");       Serial.println(index);     }  # 第六百九十一行   if(cmd[0]==flow_read_cmd)   {     Wire.write(flow_val,3);     flow_val[0]=0;         cmd[0]=0;   } # 是否要 debug     if(debug==1)     {       Serial.print("DATA = ");       Serial.print(b[0]);       Serial.print(", ");       Serial.print(b[1]);       Serial.print(", ");       Serial.println(b[2]);     } } </pre>    <span style="color: #808080;"><strong>【 grovepi.py 補丁】</strong></span> <pre class="lang:python decode:true"># 第一百五十二行 flow_read_cmd=[12] flow_disable_cmd=[13] flow_en_cmd=[18]  # 增加啟閉 debug 指令 en_debug=[254] dis_debug=[255]  # 第五百五十八行 def flowRead():         write_i2c_block(address, flow_read_cmd + [unused, unused, unused])         time.sleep(.2)         data_back= bus.read_i2c_block_data(address, 1)[0:3]         #print data_back         if data_back[0]!=255:                 return [data_back[0],data_back[2]*256+data_back[1]]         else:                 return [-1,-1] # 增加開啟除錯 def debugEnable():         write_i2c_block(address, en_debug + [unused, unused, unused])         time.sleep(.2) # 增加關閉除錯 def debugDisable():         write_i2c_block(address, dis_debug + [unused, unused, unused])         time.sleep(.2) # </pre> ───     <span style="color: #666699;"><a style="color: #666699;" href="http://www.freesandal.org/?p=47985">W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧戊</a></span>  ……  <span style="color: #808000;">或許我們也應從善如流,一探春花春景的耶!!</span>  <span style="color: #808080;"><strong>【 dtoverlay=i2c-gpio 】</strong></span>  <span style="color: #808000;">使用 i2c-gpio 預設值︰ GPIO23 是 SDA , GPIO24 為 SCL ,串接回硬體 I2C : GPIO0 SDA , GPIO1 SCL 。因此樹莓派上有兩個 I2C Master 。</span>  <img class="alignnone size-full wp-image-48045" src="http://www.freesandal.org/wp-content/uploads/Bit-Banging-I2C.jpg" alt="Bit-Banging-I2C" width="1023" height="632" /> <pre class="lang:default decode:true ">pi@raspberrypi ~ ls /dev/i2c* -l
crw-rw---- 1 root i2c 89, 1  1月 29 14:52 /dev/i2c-1
crw-rw---- 1 root i2c 89, 3  1月 29 14:52 /dev/i2c-3
pi@raspberrypi ~ $ 

都可定址 GrovePi 也。

───

 

循著足跡

W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧庚 

,續踏征途的耶!!!

 

 

 

 

 

 

 

 

 

 

 

 

 

W!o+ 的《小伶鼬工坊演義》︰樹莓派 3 三兩事之預告篇

一篇 MagPi 上的訪談︰

Eben Upton talks Raspberry Pi 3

We speak to Eben Upton to find out what makes the Raspberry Pi 3 tick….

USB and PXE network boot

Even with the chip designed and taped out in March of last year, the Foundation had some final input for Broadcom in order to add twonew features: direct USB mass storage and PXE network boot capabilities. “Gordon rewrote the boot ROM for the chip and then provided an updated boot ROM to Broadcom, saying ‘shove this in the chip, it’ll work’,” Eben laughs. “And it does!

The Raspberry Pi 3 in its full glory

The Raspberry Pi 3 in its full glory

“The other interesting thing about the chip is for all other ones the implementation work was done entirely in Cambridge; this one was a collaboration with Broadcom’s settop box engineering group in Aztec West [business park] in Bristol.”

───

 

,預告著樹莓派 3 『 boot 』之新時代的到來!

一段樹莓派論壇裡的討論︰

usb boot on pi3

by lmoss30 » Mon Feb 29, 2016 10:03 pm
I know this is probably everywhere but with the release of pi3 could someone indicate how to set the system upto to run noobs of a usb drive is this even possible or is it just the os that runs on the usb drive? And you still need something on the sd card?

………

by mimi123 » Tue Mar 01, 2016 3:19 pm
lmoss30 wrote:I know this is probably everywhere but with the release of pi3 could someone indicate how to set the system upto to run noobs of a usb drive is this even possible or is it just the os that runs on the usb drive? And you still need something on the sd card?

you can boot from USB and from network on the Pi3 without a MicroSD at all

The tools are still not public though

………

by jdb » Sun Mar 06, 2016 1:35 pm
The bootrom on Pi3 supports USB mass-storage class booting as well as tftp/PXE boot. What isn’t in place yet is a bootcode.bin that understands it’s been loaded from a USB device (and therefore should go look for a USB device/listen on tftp for start.elf).

───

 

,訴說著它並不是此刻?這其中『USB 儲存裝置』之『直接』開機尚且容易直覺明白。至於『PXE network boot』未雨綢繆者或應先了解

Preboot Execution Environment

In computing, the Preboot eXecution Environment (PXE, sometimes pronounced as pixie[1]) specification describes a standardized client-server environment that boots a software assembly, retrieved from a network, on PXE-enabled clients. On the client side it requires only a PXE-capable network interface controller (NIC), and uses a small set of industry-standard network protocols such as DHCP and TFTP.

The concept behind the PXE originated in the early days of protocols like BOOTP/DHCP/TFTP, and as of 2015 it forms part of the Unified Extensible Firmware Interface (UEFI) standard. Given fast and reliable local area networks (LANs), PXE is the most frequent choice[2] for operating system booting, installation and deployment.

PXE_diagram

A high-level PXE overview

───

 

的概念。並且能深入閱讀規範與專論︰

Legacy – PXE Boot

Red Hat Linux 下建立 PXE Server

Step 1 : 前言
Step 2 : 環境需求
Step 3 : tftp server 的設定
Step 4 : 安裝媒體(FTP,NFS,HTTP)
Step 5 : PXE 設定檔
Step 6 : DHCP Server
Step 7 : The PXE clients
Step 8 : 其他 Linux Distribution(SuSE , Turbo Linux, Ubuntu)
Step 8 : 其他 Linux Distribution(Ubuntu 11.04)
錯誤訊息

Step 1 : 前言

在安裝作業系統時最常見的方式就是透過 CD/DVD 為安裝媒體來安裝作業系統,而這邊所說的 PXE (Preboot eXecution Environment) 則是透過網路的方式進行安裝作業系統.一開始可能會覺得怎麼有可能透過這樣的方式來進行安裝作業系統,他是怎麼做到的.先說說 PXE 的歷史,他是由 Intel 所提出,最主要的目的就是希望網卡能像是 其他裝置如:硬碟,光碟,磁碟機一樣可以擔任開機的動作.所以一開始我們主機的 BIOS 必須要支援從網卡開機.

在網卡上有一塊 ROM(firmware) 裡面存放了一些基本的網路協定如:Internet Protocol (IP), User Datagram Protocol (UDP), Dynamic Host Configuration Protocol (DHCP) 以及 Trivial File Transfer Protocol (TFTP)  透過這一些協定使得 PXE 可以進行網路的存取進一步取得網路上的資源.

pxe_boot06

圖片出自於 :http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf

而 PXE 是指在作業系統前的一個作業環境,所以他最主要的工作就是將任何的作業系統載入的動作.目前多是數的網卡都支援 PXE 功能,有些甚至還支援到 iSCSI Boot 的功能.目前 PXE 已經是一個成熟的標準協定,詳細的技術可以參考 Intel 網站的 PXE 規格書.http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf

───

 

最好還能先考慮樹莓派上之實務︰

Debian: installing a PXE server on Wheezy

Table Of Contents

───

 

一旦將來若果需要,或將事半功倍的乎??!!