Previous Up Next

Diary, January 2025



Sun Mon Tue Wed Thu Fri Sat
              1   2   3   4
  5   6   7   8   9  10  11
 12  13  14  15  16  17  18
 19  20  21  22  23  24  25
 26  27  28  29  30  31


Thursday, January 2, 2025

Photograph

This evening, I bought a photograph from Paul Hendriksen that I had seen at the opening of the exhibition A day in a lifetime on December 11, last year. It is one of twenty photographs that are enlargements of a single photograph when placed in four rows of five photographs display the original photograph. I found this particular photograph the most interesting and Paul allowed me to buy this single photograph. (It is relatively easy to make the series complete again by printing the one photograph again.) While at his place, he showed me the monograph One Tree by Machiel Botman, one of his tutors. Botman takes a long time, years, to compose his monographs. I fear it is impossible to appreciate these kind books at one vieweing and that it takes careful watching and rewatching to understand them. Probably having some formal training in taking and printing photographs also helps appreciating and understanding these kind of monographs. Paul also gave me some clips such that I could put the photograph on the wall in the same manner as at the exhibition.


Friday, January 3, 2025

Wet snow

When I walked to the office, it started to snow. Some of the snow stayed on the ground. In some areas the snow stayed on the street, while at other is did not. The temperature of the ground must have been around the freezing point such that the properties of the street, such as the blackness, played a decisive role in whether or not the snow stayed. During the day some more snow fell from the sky. When I walked home I there was only some snow left in some small spots.

Watchdog timers

Watchdog timers are used in embedded systems to perform a system reset when for some reason the embedded system is not responding anymore. These are timers that after a specified time perform some kind of reset operation. To prevent the reset operation to occur, the timer need to be reset frequently. The ESP32 has several watchdog timers. According to the ESP32-S3 Technical Reference Manual (version 1.6), the watchdog timer in timer group 0 (belonging to core 0) is automatically enabled during the flash booting process. In the code of ESP-IDF it is disable again in the function bootloader_config_wdt when it is no longer needed. The watchdog timer in timer group 0 is enabled again in call_start_cpu0. No watchdog timer is enable in the function call_start_cpu1. This means that by default the watchdog timer for core 1 is not enabled. It is only possible to enabled it by software. If CONFIG_ESP_INT_WDT is enabled (defined) the watchdog timer in timer group 1 will be used for Interrupt Watchdog Timer (IWDT). Furthermore, the ESP-IDF also has a Task Watchdog Timer (TWDT), which is enable with CONFIG_ESP_TASK_WDT_INIT, that watches the idle task and makes use of the watchdog timer in timer group 0. The idle task has the lowest priority and only becomes active when other tasks are not active. If the idle tasks is not active, it probably means that some other task is running all the time. An idle task is started (by default) on both cores, but it is possible (through setting the field idle_core_mask to disable the idle tasks to be tracked by task watchdog timer. The idle tasks are created in the function prvCreateIdleTasks, which is called from the function vTaskStartScheduler. Note that there are two definitions of these function depending on whether FreeRTOS-Kernel-SMP or FreeRTOS-Kernel is used, which depends on the CONFIG_FREERTOS_SMP define. SMP stands for Symmetric Multiprocessing, which allows tasks to be scheduled across multiple identical processor cores. This should not be used when you want to dedicate one of the cores (core 1 usually) for a dedicated task.


Sunday, January 5, 2025

2cm snow and 11.2°C

At the end of the morning, there was about 2cm of snow on the table outside. This means that at least 2cm of snow fell during the evening and the morning. On ground most of the snow was already gone. The snow already had changed into rain. Until noon, the temperature at Twenthe Airport remaind between -0.4 and 0.4° Celcius. It dis not look like the prediction of 9.4° as the maximum temperature for today was goint to be reached, but around 3 in the afternoon, the temperature started to rise and between 6 till the end of the day remained around 11°C with a maximum of 11.2°C around 11 in the evening. For tomorrow a maximum temperature of 12.9°C.

ESP32: SMP

I continued my investigation with respect to running 'bare metal' on core 1 of the ESP32. I notice that I was mistaken about SMP in description about watchdog timers two days ago. The FreeRTOS SMP scheduling policy means that there is one 'instance' of the scheduler controlling task on several cores, where with the AMP scheduling policy each core runs its own 'instance' of FreeRTOS. The ESP-IDF define CONFIG_FREERTOS_SMP is about selecting an experimental SMP version of the FreeRTOS Kernel. The normal kernel verions is SMP capable.


Tuesday, January 7, 2025

TkkrLab member again

In the past half year, I have been visiting the TkkrLab hackerspace once every while. I have decided to become a member again and did so this evening.


Thursday, January 9, 2025

Some snow

When I was walking to the office, it started to snow. During the day, there was some snow, from which some did stay on parts of the ground. Some of it stayed during the evening.


Sunday, January 12, 2025

ESP32: Disabling peripheral interrupt source

On October 27, I wrote something about I²C on the ESP32 without interrupts. I suggested that idea of disabling interrupt by setting the INTERRUPT_COREx_SOURCE_y_MAP register to the value 16 (the default). Today, I read in Section 9.3.3.3 of ESP32-S3 Technical Reference Manual that setting the value to 6, 7, 11, 15, 16, or 29 will disable the interrupt source. To disable this, if it was enabled (for example when calling i2c_new_master_bus), I understand that you have to execute the following statements:
	esp_rom_route_intr_matrix(0, ETS_I2C_EXT0_INTR_SOURCE, 16);
	esp_rom_route_intr_matrix(1, ETS_I2C_EXT0_INTR_SOURCE, 16);
The ETS_I2C_EXT0_INTR_SOURCE is found in the SoC specific interrupts.h file in the soc module.


Tuesday, January 14, 2025

Prospects & Concepts

Today, I received two Prospects & Concepts catalogues about the young artist that were supported by the Mondriaan Fonds and exhibited their works at the Art Rotterdam exhibition. I bought both wooks last Sunday. The books are:


Thursday, January 16, 2025

Fancy Tetris Wooden Puzzle

Some time ago, I found this 'Fancy Tetris Wooden Puzzle' measuring 15×22cm, which is using the same types of pieces as the Chinese Wooden Puzzle. It does not have five pieces of each type, but only three, except for the yellow and the purple type, which have four pieces each. Please note that in this puzzle, the colours on the white and purple types are swapped. The pieces fit in a grid of 8 by 12. Last weekend, I started a modified version to calculate the number of solutions. The program is still running and it still might run for some time. Below it shows one solution where the pieces of the same type are all connected with each other but minimally touching each other.


Saturday, January 18, 2025

Into the city

At Fotogalerie Objektief, I saw the exhibiion 'Gewaande Landschappen' (which in English can be translated as: 'Imagined Landscapes') with photographs by Hans Bouma. At 14:45, I bought the book De Godenmakers written by Frank Herbert in Dutch, translated by Lucien Duzee from the English The Godmakers, published by Het Spectrum in 1994, ISBN:9789027440457, from Het Goed for € 2.60.


Sunday, January 19, 2025

Mutual exclusion with atomic memory operations

I have thought that for low-level mutual exclusion you need a test-and-set operation. In the past day, I realized that it can be achieved with atomic memory operations. An atomic memory operation is where you can retrieve and store the contents in one undividable operaton. This is usually the case when reading or writing a value to/from a memory cell into the register of a CPU. For values larger than the size of a register have to be loaded with multiple instructions and usually do not have the atomicity property. The idea is to use two memory locations, 'A' and 'B', where is one process (the lock server) that copies the contents of 'B' to 'A' if 'A' has the value zero and that there are multiple proceses each with a unique identifier that when needed mutual exclusion (a lock) write their identifier to memory location 'B' if 'A' and wait until 'A' becomes equal to their identifier. If 'A' becomes zero again, they will write their identifier to 'B' again. To release a lock (when they leave the mutual exclusive section) they set 'A' to zero again. This morning, I believe that the following PROMELA code proof this:
byte n = 0
byte A = 0
byte B = 0
proctype Client(byte id)
{
    do
    :: (A == 0) -> B = id
    :: (A == id) -> 
        n = n + 1;
        assert (n == 1);
        n = n - 1;
        A = 0
    od
}
proctype LockServer()
{
    do
    :: (A == 0) -> A = B
    od
}
init {
    atomic {
        run LockServer();
        run Client(1);
        run Client(2);
        run Client(3);
    }
}
It fails when two processes have the same identifier, for example, when Client(2) is replaced by Client(1) in the above code.

ESP32-S3: reset I²C

Yesterday evening, I discovered that the reset of the finite state machine of the I²C of the ESP32-S3 is not implemented. In the soc_caps.h file it says:
// FSM_RST only resets the FSM, not using it. So SOC_I2C_SUPPORT_HW_FSM_RST not defined.
//ESP32-S3 support hardware clear bus
#define SOC_I2C_SUPPORT_HW_CLR_BUS  (1)
This basically means that you have to shut-down the I²C peripheral, perform an optional bus reset, and start-up the peripheral again. I think you can use the following low-level code, which works on memory mapped hardware registers, to shut-down the I2C0 periperal:
    // Save the current settings
    i2c_scl_low_period_reg_t scl_low_period = I2C0.scl_low_period;
    i2c_scl_high_period_reg_t scl_high_period = I2C0.scl_high_period;
    i2c_scl_start_hold_reg_t scl_start_hold = I2C0.scl_start_hold;
    i2c_scl_rstart_setup_reg_t scl_rstart_setup = I2C0.scl_rstart_setup;
    i2c_scl_stop_hold_reg_t scl_stop_hold = I2C0.scl_stop_hold;
    i2c_scl_stop_setup_reg_t scl_stop_setup = I2C0.scl_stop_setup;
    i2c_filter_cfg_reg_t filter_cfg = I2C0.filter_cfg;
    i2c_clk_conf_reg_t clk_conf = I2C0.clk_conf;
    bool fifo_mode_en = I2C0.fifo_conf.nonfifo_en;
    // Disable the peripheral
    SYSTEM.perip_clk_en0.i2c_ext0_clk_en = false;
To start-up the I2C0 peripheral again (with the saved settings), I think you can use:
    // Enable the peripheral
    SYSTEM.perip_clk_en0.i2c_ext0_clk_en = true;
    // Reset the peripheral
    SYSTEM.perip_rst_en0.i2c_ext0_rst = 1;
    SYSTEM.perip_rst_en0.i2c_ext0_rst = 0;
    // Set the default configuration (for master)
    i2c_ctrl_reg_t ctrl_reg;
    ctrl_reg.val = 0;
    ctrl_reg.ms_mode = 1;
    ctrl_reg.clk_en = 1;
    ctrl_reg.sda_force_out = 1;
    ctrl_reg.scl_force_out = 1;
    I2C0.ctr.val = ctrl_reg.val;
    I2C0.ctr.tx_lsb_first = I2C_DATA_MODE_MSB_FIRST;
    I2C0.ctr.rx_lsb_first = I2C_DATA_MODE_MSB_FIRST;
    // Reset FIFO buffers
    I2C0.fifo_conf.nonfifo_en = fifo_mode_en;
    I2C0.fifo_conf.tx_fifo_rst = 1;
    I2C0.fifo_conf.tx_fifo_rst = 0;
    I2C0.fifo_conf.rx_fifo_rst = 1;
    I2C0.fifo_conf.rx_fifo_rst = 0;
    // Disable and clear interupts
    I2C0.int_ena.val &= (~I2C_LL_INTR_MASK);
    I2C0.int_clr.val = I2C_LL_INTR_MASK;
    // Restore saved settings
    I2C0.scl_low_period = scl_low_period;
    I2C0.scl_high_period = scl_high_period;
    I2C0.scl_start_hold = scl_start_hold;
    I2C0.scl_rstart_setup = scl_rstart_setup;
    I2C0.scl_stop_hold = scl_stop_hold;
    I2C0.scl_stop_setup = scl_stop_setup;
    I2C0.filter_cfg = filter_cfg;
    I2C0.clk_conf = clk_conf;
Note that in the function s_i2c_hw_fsm_reset the peripheral is not disabled and enabled again, like it is in the function i2c_hw_fsm_reset. To clear the I²C bus, a specific sequence of signals on the clock and data lines is used. It seems that can be done by calling the function s_i2c_master_clear_bus. (In i2c_hw_fsm_reset this is called when the peripheral is disabled, suggesting the idea that it can be executed without it being enabled and being some function outside the normal circuitry.) Because SOC_I2C_SUPPORT_HW_CLR_BUS has the value (1) for ESP32-S3 the following code can be used to start the bus reset procedure that exists of nine pulses as defined by the value of I2C_CLR_BUS_SCL_NUM.
    I2C0.scl_sp_conf.scl_rst_slv_num = I2C_CLR_BUS_SCL_NUM;
    I2C0.scl_sp_conf.scl_rst_slv_en = 1;
    I2C0.ctr.conf_upgate = 1;
However, the function i2c_ll_master_is_bus_clear_done always returns false, which results in the time-out to be triggered and that the function s_i2c_master_clear_bus returns the ESP_ERR_INVALID_STATE error. The time-out period is 50ms as defined by I2C_CLR_BUS_TIMEOUT_MS. From the fallback code in the function, I understand that the whole bus reset sequence is 100µs. A time-out period of 1ms should be enough for the bus reset sequence to be finished. After the time-out, the i2c_ll_update function is called, which equals to the following for device I2C0 for the ESP32-S3:
    I2C0.ctr.conf_upgate = 1;
The code of i2c_master_clear_bus does not have the time-out check, without which it would run indefinitely, it seems that the function i2c_hw_fsm_reset is not called for the ESP32-S3.


Monday, January 20, 2025

IJsdagen

We have had three days where the maximum temperature stayed below zero degrees Celsius. In Dutch these days are called 'ijsdagen'. Last winter we did not have any such days, so, with these 'ice days' the longest sequence on record of days that the maximum temperature stay above zero has ended. The Dutch word for ice is 'ijs' en the Dutch word for days is 'dagen'. The word 'ijs' starts with the digraph ij, which is usually captilazed as IJ, which rather exceptional. There are also Unicode character for this digraph: ij and IJ.


Friday, January 24, 2025

B93 Anno Nu

This afternoon, I went to see the exhibition B93 Anno Nu - Het is duur en niet ongevaarlijk, which translated to English is: B93 Now - It's expensive and not without danger. I did not go to the opening (in English) on January 8, but today there was another opportunity to see the exhibition. I did like the exhibition. I found the following works (in random order) noteworthy:


Wednesday, January 29, 2025

DeepSeek

I asked DeepSeek what it knew about me and it gave a gross exaggerated description that seemed to be based on some true facts about me, which can only mean that they trained their model on data that included my name and information about me. Possibly including my website. When I asked ChatGTP the same question it replied that I 'doesn't appear to be a widely recognized figure in global media or history'. Should I be worried that a Chinese company as an LLM that knows this kind of information about me? What kind of information have the Chinese collected about me?


Friday, January 31, 2025

Fancy Tetris Wooden Puzzle

In the past weeks, I continued finding the solutions for the Fancy Tetris Wooden Puzzle. Because the existing program finds many double solutions in the sense that some combinations of pieces result in the squares being coloured in the same way, I worked on some function to eliminate all these combinations, such that the program will run faster and such there is no longer a need to sort the output and remove all double solutions. Especially, the blue pieces, a bit to my surprise, had many combinations resulting in the same colouring. Next, I also wrote a function to remove combinations that can never lead to a solution, because the divide the a space up into pieces with an area that is not possible to be filled with any combination of other pieces. The table below gives the number of combinations for the various colours of the pieces. The first column gives the names. The second column the number of combinations not taking into account combinations that cover the same squares. The third column is the number of combinations where combinations resulting in the squares to be covered are filtered out by the program. The fourth column gives the number where combinations that never lead to a solution are filtered out and are processed with sort -u to find the combinations that cover the same squares. The fifth column gives the number when both tests are implemented in the program. In the sixth column the rows where the fourth and fifth column differ are marked. This means that for those kind of pieces the algorith for eliminating solutions that cover the same squares, does not work correctly. I wonder if my program for solving Exact Cover problems can deal with a total of 1981586 rows and if it would be faster than the program that I wrote for the Chinese Wooden Puzzle. The program that prevents 'double' solutions, finds about 25 milion solutions per day.

Orange     96744    96744    45260   45260
Red        84024    80424    65236   65272 *
Yellow   1758146  1656943  1035463 1057409 *
Blue      882168   812388   664608  664608
Green       1734     1734     1626    1626
Black      14830    14830    13666   13666
Purple     82708    66648    60524   64817 *
White      84736    79752    68928   68928


This months interesting links


Home | December 2024 | February 2025 | Random memories