sf read: 讀取 flash資料到記憶體
sf write: 寫入記憶體資料到flash
sf erase:刪除指定位置,指定長度的 flash 内容, 刪除後内容全為 1
使用說明
sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus and chip select
sf read addr offset len - read 'len' bytes starting at 'offset' to memory at 'addr'
sf write addr offset len - write 'len' bytes from memor at 'addr' to flash at 'offset'
sf erase offset [+]len - erase 'len' bytes from 'offset' + 'len' round up 'len' to block size
sf update addr offset len - erase and write 'len' bytes from memory at 'addr' to flash at 'offset'
使用範例
sf probe
在使用sf read sf write之前,一定要先用sf probe
sf write 0x20000000 0x0 0x10
把記憶體中0x2000 0000的資料, 寫入flash的0x0, 寫入資料長度為0x10, (注意:flash的位置以及寫入長度度最單位位是Byte)
sf read 0x20000000 0x10000 0x10
把flash位置0x10000, 長度为0x10的資料, 寫入到記憶體0x20000000, (注意:flash的位置以及寫入長度度最單位是Byte)
sf erase 0x0 0x10000
刪除flash的0x0, 長度為0x10000的資料, 刪除是以erase block為單位, offset和len參數必須要跟erase block對齊的。
支援平台
Target Arch. Host OS
----------------------------------------------------------
windows. (32 / 64) Any
android(+Wear) arm Any
Linux 64 Any
macOS 64 macOS
iOS (arm + arm64) macOS
Raspberry Pi arm Any
MAC
ref: https://unix.stackexchange.com/questions/145651/using-exec-and-tee-to-redirect-logs-to-stdout-and-a-log-file-in-the-same-time
./exe &> >(tee -a "$log_file")
本篇cross-compile工具只有設定windows x86, x64, linux x86, x64四種,其他平台請參考下列原文敘述進行修改。
$GOOS and $GOARCH
The name of the target operating system and compilation architecture. These default to the values of $GOHOSTOS and $GOHOSTARCH respectively (described below).
Choices for $GOOS are darwin (Mac OS X 10.7 and above and iOS), dragonfly, freebsd, linux, netbsd, openbsd, plan9, solaris and windows. Choices for $GOARCH are amd64 (64-bit x86, the most mature port), 386(32-bit x86), arm (32-bit ARM), arm64 (64-bit ARM), ppc64le (PowerPC 64-bit, little-endian), ppc64 (PowerPC 64-bit, big-endian), mips64le (MIPS 64-bit, little-endian), and mips64 (MIPS 64-bit, big-endian). The valid combinations of $GOOS and $GOARCH are:
# echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
# sudo apt-get update
get Error :
GPG error: http://hyperrate.com eliu Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5C577D59835AB0E3
int flags:The flags parameter can be used to influence the behavior of the function beyond the options specified for the associated socket。(一般設 0)
MSG_DONTROUTE:不將訊息送給 gateway,而直接送給 host。(Specifies that the data should not be subject to routing. A Windows Sockets service provider can choose to ignore this flag.) MSG_OOB:Sends OOB data (stream-style socket such as SOCK_STREAM only)。
const struct sockaddr *to:目的地位址資訊。
int tolen:目的地位址資訊的大小。
成功回傳傳送的資料長度,失敗回傳 SOCKET_ERROR。
8.接收訊息。[server端] [client端] 函式 1:int recv(SOCKET s, char *buf, int len, int flags) 函式 2:int recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen)
int flags:The flags parameter can be used to influence the behavior of the function invocation beyond the options specified for the associated socket.。(一般設 0)
MSG_PEEK:Peeks at the incoming data。只看訊息內容,但不將訊息從 queue 移除。 MSG_OOB:Processes Out Of Band (OOB) data。
const struct sockaddr *to:目的地位址資訊。
int tolen:目的地位址資訊的大小。
成功回傳接收的資料長度,連線被關閉回傳 0。失敗回傳 SOCKET_ERROR。
9.設定 socket option 選項。[server端] [client端] 函式 :int setsockopt(SOCKET s, int level, int optname, const char *optval, int optlen) 用來設定建立的 socket 一些特性,例如是否強制關閉等。 10.關閉 socket。[server端] [client端] 函式 :int closesocket(SOCKET s)
listen(sListen, SOMAXCONN);//SOMAXCONN: listening without any limit
//等待連線
SOCKADDR_IN clinetAddr;
c = sizeof(struct sockaddr_in);
while( (sConnect = accept(sListen , (struct sockaddr *)&clinetAddr, &c)) != INVALID_SOCKET ){ puts("Connection accepted");
//Reply to the client
message = "Hello Client , I have received your connection. But I have to go now, bye\n";
send(sConnect , message , strlen(message) , 0);
puts("Connected");
//Receive a reply from the server
if((recv_size = recv(sConnect , server_reply , 2000 , 0)) == SOCKET_ERROR){
puts("recv failed");
}
puts("Reply received\n");
//Add a NULL terminating character to make it a proper string before printing server_reply[recv_size] = '\0';
puts(server_reply);