I²C for BadgerOS (Part 2)
Yesterday, I wrote the first part of I²C
for BadgerOS. Today, I continue a bit further in understanding how it works.
The functions called in the file managed_i2c.c are found in the file
i2c.c of the Espressif IoT Development Framework. The functions
i2c_write_reg and i2c_read_req, each build a list of
'commands' which are then executed by calling the function i2c_master_cmd_begin. This function also calls the function
i2c_master_cmd_begin_static for sending the commands to the hardware
calling various i2c_ll_ functions, which are platform specific. For
the ESP32-C6 these are found in the file hal/esp32c6/include/hal/i2c_ll.h. The letters hal stands
for hardware abstraction layer. I guess that the letters ll stand for
low-level.
I²C for BadgerOS (Part 3)
From studying all the files, yesterday and the day
before, I am still puzzled with some things. I went back to the Hackerhotel 2024 CH32V003 firmware repository and noticed that the
function I2C1_EV_IRQHandler in the i2c_slave.h is nowhere
called in the code. I presume that it is called from 'hidden' part of the
firmware that is provided as a binary. I wanted to know if multiple
I2C_STAR1_ values can be set. The code suggest that it might be the
case, using multiple parallel if-statements and the bitwise-and operator. When
I googled for I2C1_EV_IRQHandler, I found that it is also used in code
to program microcontrollers from STMicroelectronics. There the use of chained if-else-statements seems to
suggest to always at most one flag is set. (This is not particular good code
design, to use bit-flags for excluding values. Maybe designed with the idea of
that in the future they might occur at the same time.) So, if I understand it
correctly there are two types of interactions on the I²C bus:
- A write operation of a number of bytes, where the first byte specifies the
starting position and all following bytes are data written to the
locations (registers) starting from the specified position going up.
- A read operation of number of bytes, starting from the last specified
position going up, where typically the position is set with a write
operation with zero data bytes.
On the I²C bus both operations start with a byte specifying the identifier
of the slave peripheral and a bit-flag specifying whether it is a write or a
read operation. (This is for the 7-bit address mode. For the 10-bit address
mode, two bytes are used.)
The code of the function i2c_master_cmd_begin_static is not so easy
to understand. One reason that is that it not only called from the function
i2c_master_cmd_begin but also from the function
i2c_isr_handler_default, which is the interupt handler that is called
when reading, when the command is longer than the size of the FIFO hardware buffers, and/or when other events occur. The function starts
with some code for dealing with a read command. The low-level function
i2c_ll_read_rxfifo is used to read information from the FIFO read
buffer that is filled during receiving the data over the I²C bus. For the
ESP32C6 this is done by reading from a certain memory location that maps on
a hardware register and which, I presume, also removes the value from the
buffer. In the while-loop, the commands are processed, calling the function
i2c_ll_write_cmd_reg to tell the hardware about the function to
perform.
Is there anything to improve on this implementation? I wonder if instead of
using a linked list for storing information about the command, where the
elements are allocated one-by-one, it would be possible to use an array that
is allocated on the stack or as a global variable. It states that the function
i2c_master_cmd_begin only return after all the commands have been
sent out (or when the specified time-out period is reached). I also guess,
that when this needs to be implemented in BadgerOS, that some of the
primitives, such as the locking and the event queues, that are used, need to be
replaced by equivalent primitives in the kernel of BadgerOS. As the I²C
bus is usually used to read out input and output devices on the badge, that the
code to access those devices will need to be implemented as a service running
within the kernel and that the process (that has the 'focus') will have access
to those through a system call implemented by the kernel. When that is the
case, the code cannot be 'blocking' in anyway and probably has to run in
parallel with other code that communicates with peripheral, such as for
example, WIFI. I do not have a clear picture how that should be implemented.
The temperature at Twenthe Airport has gone up to
29.5° Celsius, which breaks the previous record of 29.2° on this date
in 1991.
Hokuyo URG-04LX-UGO01 lidar
I am trying to get some data from a URG-04LX-UG01, which is a URG-04LX Scanning Laser Range Finder (Speccification that has a mirco-USB port. The scan area is a 240°
semicircle with a maximum radius of 4 meter. The pitch angle is 0.36° and
the sensor outputs the distance measured at 683 different angles. The laser
beam diameter is less than 1 cm at 1 meter distance. I read that the angular
resolution is configurable by the host. URG Series: Communication Protocol Specification.
After the usual trouble, I managed to build the hokuyoaist_example
program from the gbiggs/HokuyoAIST github repository. For this you first need to
install Doxygen, Sphinx, the Sphinx Breathe
plugin and Flexiport:
Flexible communication library. Note that the later needs to be installed
(with make install) before running cmake for HokuyoAIST. When
I run the program, without any arguments, it does return a lot of messages,
including error messages, but I do not see anything that looks like data. On
linux you can also just simply connect to it with minicom using the following command:
minicom -D /dev/ttyACM0 -b 19200
You can use the keystroke sequence 'Ctrl-A z u' to add a carriage return after
each life-feed as the sensor will only return line-feed characters. Now you
can enter command such as 'VV', 'PP', 'II' and 'GD0100020002' (followed by
an enter) to retrieve information or data from the device. I looked into the
code and I discovered a bug in the method
hokuyoaist::ScanData::as_string where an unsigned integer was
initialized with -1. When I changed that to 0, the program does show data. If
you are given it clustring value (with the '-c' command line option) the range
should be a multiple of this, otherwise an error is reported.
Today, I have been experimenting with visualizing Live-bootstrap using tombstone diagrams (or T-diagrams) where each T-shaped diagram represents
on process that is executed. Below the result of this experiment, which only
rather incomplete and not well aligned. It is incomplete because it only gives
the initial thirdteen processes. Also I still have to add connect lines. I am
thinking about calculate all the coordinates based on the positions of the
elements based on the widths of the texts. I also have to think about how to
list the input files. Some of processes have multiple input files, which can
be a mixture of files produced by other steps and given input files. Some
input files are used as input for multiple processes. The grey boxes are used
to visualize the execution of processes by other process. Dragging and zooming with the mouse can be used to view the whole diagram.
Chestnut and musterd seeds
At 12:19, Conny gave my a large chestnut she just found on the street. This evening, I went to
Herenboeren Usserler Es to help, with about
twenty other members, to harvest the musterd seeds. We had to strip the pods
with the seeds from the leaves and break open the pods. We used some sieves to
seperate the seeds from the pods and bits of branches. The result needed more
processing. We guessed that we had harvest about 4 kilo of musterd seeds. We
were also allowed to get ourselves some buckwheat plants. They did not contain
much seeds and might need some more time before they are to be harvest.
Amsterdam
On the way to Amsterdam, I first visted Utrecht where I went to bookshop
Steven Sterk and Aleph books. In Amsterdam,
I took the Metro line M52 to Rokin and walked to bookshop Scheltema. The section with ramsj books has moved to a different location
on the top floor and has been reorganized, which felt like an improvement. I
few floors lower, I found the book Strange Code: Esoteric Languages That Make Programming Fun Again by
Ronald T. Kneusel and when I paged
through the Chapter 10, which about Brainfuck, I found my name printed on
page 293 with a link to my pages about it.
Next, I paid a short visited to bookshop De
Slegte, walked over the open air bookmarket on Het Spui, and visited the
American Book Center. From there I walked to Galerie Ron Mandos to see the exhibition
Best of
Graduates 2024. I found the works of the following graduates noteworthy in
the order I saw them:
Next, I walked to gallery andriesse &
eyck to see the exhibition Colour Changes in Two and Three Dimensions 1979-2014 with works by
Peter Struycken. Besides Peter Struycken, I
talked with several people who I already knew. I also met with the artist
Wilfried Lansink.
Books
At 13:50:19, I bought the following three books from charity shop Het Goed:
- Xaveer De Geyter Architects: After-sprawl : Onderzoek naar de
hedendaagse stad written by Geert Bekaert in Dutch and published by NAi Publishers in January
2002, ISBN:9789056622640,, for € 2.80.
- Don't Eat The Yellow Snow: Pop Music Wisdom written by
Marcus Kraft in English and
published by Laurence King Publishing in 2013,
ISBN:9789063692889, for € 3.40.
- Edwin Kragten: Houtskooltekeningen 2006-2008 written by Adriën
Cozijnsen in Dutch,
ISBN:9789081029438, for € 1.50.
This year I am volunteering again for the GOGBOT
festival. In the evening, I took the role of a guard/guide at Grote Kerk
(the Large Church) where in the main hall there were two large artworks:
- Depth Array by
Robin Beekman, which I had already
see earlier this year at Raidiant Voids on February 2. (I feel that the work did less well in the large hall of
the church than it did there. Also, I feel that due to the large volumes
of people that could just freely walk through the room, it would have been
beter if the sequence of effects were restricted to those best showing the
'depth' effect.)
- ATEM (German for breath) by
AUSGANG studio. (With an interfall
of about half an hour, the work would perform some special operation for
the people who got 'inside' the work. I found it a bit of a pity that it
did not do this more often, because many people got dissappointed that they
had to wait a long time to have an opportunity to experience it.)
In the tower of the church there the artwork Dépaysement by Isabel Waller.
GOGBOT: Day 2
This afternoon, I did my second volunteer shift at the information desk. There
were not many people. I did watch Kees de Groot finish his art work. After the shift, I went to
Rijksmuseum Twenthe where I (rather quickly)
walked through the exhibition Gogbot x RMT (also called: The Tec Divide, where I saw the
following art works:
- A Bestiary of the
Anthropocene, Disnovation.org, 2021.
- Technosamanic Systems: New Cosmological Models for Survival,
Suzanne Treister, 2020 - Now.
- You are Light an Cabbage, Diana Gheorghiu, 2023.
- Irma Watched over by Machines, Troika, 2019.
- Forest filled with pines and electronics, Troika, 2022.
- Calculating Empires: A Genealogogy of Technology and Power,
1500 - 2025, Kate Crawford
& Vladan Joler. (Very large
and detailed inforgraphic.)
- Retraining Laziness, T(n)C /
Tina Kult and Agnes Varnai, in collaboration with Madeline Hall, 2023.
- 564 Tracs (
Not a love song is usually a love song),
Miloš
Trakilovió, 2023.
- A Boring Dystopia, Matthias Planitzer, 2023.
- The Materiality of a Natural Disaster, Hilda Hellström, 2012.
I also walked through the exhibition PLANETART ARCHIVES X Kees de Groot 1978-2003. I am probably going to
revisit these exhibitions at a later time. I went back to the city center
where I saw the following art works, which are part of GOGBOT:
After having dinner at home, I went back in the evening and watched:
GOGBOT: Day 3
I again did a volunteer shift at GOGBOT
handing out program flyers near the entrences. At 16:07, I bought the book
P.L.A.N.E.T.A.R.T. The History of Kees de Groot and PLANETART 1978 - 2004
written by Lars van der
Miesen in English and published by PLANETART Publishers in 2024,
ISBN:97890903888144, from underbelly for
€ 20.00. It is the catalogue with the exhibition
PLANETART ARCHIVES X Kees de Groot 1978-2003 and the online
PLANETART Archive.
GOGBOT: Day 4
This afternoon, I did my last volunteer shift for this year of the GOGBOT festival. I took the role of a guard/guide at Grote Kerk (the
Large Church) again, but now it was during the day instead of during the
evening as on the first day. I think a different type of
public came to visit the church. More elderly people and familis with young
children. Going from the bright outside into a dark church caused many to not
enter the mail hall of the church afraid to tripping. I told people that there
were no thresholds and/or that the floor was flat. Some people, primarily young
children, found the lights of the Depth Array work scarry. However, I did notice a wide range in reactions.
Tombstone diagram for live-bootstrap
In the past weeks, I have been working on generating tombstone diagrams (or T-diagrams) for Live-bootstrap based on the output produced by strace. I have published
the results here on github. You can zoom and pan with the mouse. If you click on a
process (T-shaped) or a file, it will show additional information. If you
click on a link in the additional information, the process or file will be
centered in the diagram and highlighted with a yellow back-ground.
Self-driving wheelchairs
Today, in the news, there was an item about self-driving wheelchairs on
Amsterdam
Airprot Schiphol. These are produced by WHILL
Inc.. They have some repositories on
GitHub. There is a repository
about fiducual
markers, which also has a reference to fiducuals on ROS.org. With fiducial markers placed on the ceiling, it is possible to
determine the position of a wheelchair using a small camera. I also had to
think about Dynamicaland where markers
are used to determine the location of documents and/or cards on a table.
Japanese newspaper
Some days ago, we received a bottle of Nin Jion Pei Pa Koa that we had ordered online. It came with a box with
a Japanese paper. Today, I found the link https://www.chunichi.co.jp/chuspo printed on the front page, which is the
'last' for English readers. Japanese number the pages in the reverse order. On
the first pages the text on the lines runs from top to bottom and the lines
run from right-to-left. On the latter pages the text on the lines runs from
left-to-right with lines going top-down. The link is to the website of the
Japanese paper Chunichi Shimbun. It is the issue from April 2 this year. On page 16, I
recognize a sudoku puzzle. It looks like there are also a Shogi and a Majong
related puzzles.
World of Industry, Technology & Science
I visited the World of Industry, Technology
& Science exhibition the Jaarbeurs in Utrecht. I spend a large part of my time there flashing
firmware to the gadget of the
World of Electronics, an environmental sensor with a solar cell that can be
placed outside and is ready to send measurement data to openSenseMap. Visitors who had registered for the gadget had to visit a
number of stands to collect the various parts and then have the firmware
flashed. The gadget is build around a SMT32L072RZ and has the following sensors: temperature, humidity,
a microphone (to measure sound levels), and a volatile organic compound gas sensort, with the posibility to add
a SEN5x environmental sensor node for HVAC and air quality applications.
After the exhibition, I walked into the center and visited the Steven Sterk bookshop, where at 17:48, I bought the book Brieven,
dagboeken en een geheime liefde with letters, diary notes, and a novel by
Laurie Langenbach with an introduction by Rutger Vahl, written in Dutch and
published by Singel Uitgeverijen in 2017,
ISBN:9789029511834, for € 12.50.
Hackfest: Day 1
Around 12, I arrived at Hackfest, which
is held here in Enschede. I met several people, I had not seen before. At
13:00, I joined the lecture You Need a Hackerspace! by Mitch Altman. At 14:00, I joined the lecture Introductie MQTT, Tasmota
& Node-RED by Ad (CrazyA). At 15:00, I joined the lecture Dutch
(home) computer history by Bart van den Akker from Home Computer Museum with some interesting facts about the Dutch history
with respect to home computers. I learned that the Netherlands was the first
to have an educational television series by Teleac in 1978 about the mircoprocessor given by Chriet Titulaer. The lecture also mentioned the Aesthedes a computer graphics or computer-aided design system that was
introduced to the market in 1984. I talked with some old friends and missed the
first part of the lecture Ravi the theatre robot by Edwin Dertien, a very interesting talk. Afterwards, I talked a bit with
him. The last talk, I went to see was 28 kinds of uncertainty in science and
technology, by Frau Heisenberg. It was not very long, but quite funny.
At 19:30, I followed with half a eye, the demoscene showcase by Okkie. Between
20:30 and 22:00, I also watched the live coding for fun with TIC-80. There were four people joining in this. Some had more experience
than others. It looked like fun but I do not know if I would like to join in
the next time.
Hackfest: Day 2
At 11:00, I attended the lecture Building your own ISP _or_ How to become
sovereign on the internet by Nick
Bouwhuis. At 12:00, I gave my lecture The live-bootstrap project. I spend some talking with various people
including some of the makers at their booths, such as:
At 15:00, I joined the lecture Live & work without Google, Meta, Apple
or Microsoft? It can be done! by Björn Wijers. At 16:00, I listen to the lecture Verifiable
Computing Project – Building Truly Open Source Hardware by Joyce Ng (Presentation).
On the way home, I bought some gerkins and sour herring for the curly kail hotchpotch Conny had prepared.
This months interesting links
Home
| August 2024
| October 2024