In terms of the firmware development, there are 2 major pieces left, which is the message transmission and the display integration. This week, I worked on the message transmission to prep for the interim demo. LoRa message transmission was simulated using 2 Meshtastic nodes, and the messaging interface has been integrated into the UI so that users can select a contact, input a message, and view incoming and outgoing messages.
We are a bit behind on the firmware development as I’d like to be. The physical LoRa integration is still blocked because the module/hardware hasn’t been delivered. The simulation was a mitigation to verify the workflow in software and reduce future integration work. If the module arrives next week and I can finish the physical integration, firmware should be back on schedule.
Next week, I will be prepping for the interim demo and also working on the radio driver and replacing the simulated interface with the physical LoRa module.
This week I was scheduled to work on running the emulator on the dev board, and third-party applications on the emulator.
We have demos during the coming week. Our new PCB got delayed, so our dev boards right now have no display. While seeing tests pass without a screen is meaningful to me, it doesn’t provide a very good demo. Therefore, I’ll show the emulator executing on my laptop for the demo. As a consequence, I’ve prioritized running third-party apps over dev board work, and so I’ll extend that by another week.
We can install apps now! Out of the box, PalmOS stores applications along with other persistent data in half of RAM. Typically, apps are installed over HotSync, which I believe is backed by the VZ’s UART. However, the UART device is not sufficiently fleshed out to use HotSync, and I don’t have a HotSync client. Setting it up would take a great deal of work. On the other hand, we could develop a library that writes the correct database entries to persistent memory without involving PalmOS at all – but this requires digging into implementation-specific behavior.
Fortunately, we can exploit a different well-understood interface: the PalmOS ABI! I mentioned previously that it’s a massive surface to emulate, and that there isn’t really any user/supervisor separation in PalmOS, which is why we aren’t reimplementing the ABI. These disadvantages are actually advantageous here: to install an app, we can inject a sequence of traps into the ABI to persist the app binary! It feels a bit like black magic to hijack the guest OS to upload an app, but it has the least room for error of our options.
For running on the P4, I’ve reworked the system to receive events on channels. That’s sufficient for testing, and for interactive use it will just take a refactor to use FreeRTOS queues instead. I’m not truly processing interrupts yet; I still wait for the last interrupt to finish before delivering the next, regardless of priority. But it works! It also lets me add debouncing, in case e.g. touchscreen interrupts on the P4 are too frequent.
The coming week will focus on pulling a lot of different apps from PalmDB and testing them, to try and smoke out bugs in the implementation. I will also be continuing work on the dev board.
Please enjoy my game of 2048, and politely ignore the parts where I have to stop and think after not having played since 2017 🙂
Previously, we ordered the PCB unassembled and ordered the parts separately, since it was not possible to source the processor directly from JLCPCB. We had done so because we had thought it would be too difficult to use a stencil to apply solder paste to the unassembled portion of the PCB when the rest of the PCB was assembled.
This week, we attempted to assemble the PCB, but although the substitution of the WT0132P4-A1 module for the ESP32 module was a successful solution for easier sourcing and solder paste application, we found that some of the pads for the other ICs were too small to solder ourselves. However, since the stencil came with a lot of extra space around the holes, and the parts that we would need to solder on our own (namely the processor with its associated pull-ups, along with the LoRa module) were limited to one side of the board, we determined that we could cut the stencil and still be able to tape the board in place to apply the solder paste to the unassembled portion. As a result, we decided to reorder the board with most of the components assembled, but solder the through-hole components ourselves, along with the mentioned modules on the left side of the board using the TechSpark reflow oven.
This is a bit of an unfortunate setback- I have used up most of my allocated slack time, which means that I am now slightly behind schedule. We may or may not receive the new PCB by the interim demo, but after that, I should still have a week to test and reorder one more iteration in order for it to arrive by the final demonstration. The larger problem is going overbudget- while we are reusing as many components as possible (along with the stencil) since we already ordered them, the wasted shipping and customs costs for the original fabrication, along with the cost of the parts (namely ICs) that we won’t be able to use, will put us slightly overbudget if we need to make one more order. We will discuss this with our advisor and TA on Monday.
Over the past week, we received our PCBs and the remainder of our components. We’ve also been hard at work on the firmware and software. Overall, we are just about on schedule.
On the hardware side, this week was set aside for testing the PCB, and we ran into a roadblock. We pivoted from purchasing pre-assembled boards to doing all soldering ourselves for cost, but we collectively missed some components that had pads underneath with small pitch. Unfortunately, we do not have enough experience with reflow to guarantee no bridges at small pitches, and pads underneath ICs means that we would need the X-Ray to inspect joints and need a more complex reworking setup than a soldering iron (but the Scorpion in the ECE Fab is currently out of commission). Several things needed to go wrong for us to get here – and fortunately we are prepared for that.
Because of the risk inherent in printing out a PCB, our schedule built in time for a second draft. This was very effective for risk mitigation, because we ran into problems assembling the board. We are adjusting our second draft to be earlier, with the intention of receiving it before our demo. I’ve attached an updated schedule below. However, buying pre-soldered pushes us above our budget; we only have money for printing bare PCBs. This is something we are discussing with course staff.
Firmware development is moving along. Now that more peripherals have arrived, we can develop and test our code more thoroughly. Maggie has been exercising several components on a breadboard and measuring results with the GPS. Now that more time has passed and familiarity has been built, Maggie and Tucker have also been working on clarifying the interfaces and interactions between the hardware, firmware, and emulator. A major risk in our firmware process is the “unknown unknowns” – finding out that a chip has undocumented behavior, or that we did not anticipate a need of the software – and we are mitigating this by validating early.
The emulator is now interactive, performant, and viable for running the OS itself. This week is focused around evaluating it on the dev board, as well as pulling in third-party Palm apps. One major risk remaining is that we did not completely anticipate resource or interface needs of the emulator. Tucker has been measuring it already and designing around the hardware abstractions we specified, giving us an opportunity to discuss and adjust. That will continue this week. There is also a risk of untested Palm apps performing unforeseen actions, and therefore failing to work correctly. PalmOS does not isolate applications or mediate access to hardware; our only mitigations are to implement the emulator with an adversarial mindset and to cast a broad net in our testing.
Last week, I reported that I was slightly behind schedule. I’m happy to report that the emulator stack is back on track, and it’s been a fun challenge to get to this point.
I am very excited to report that it is now interactive, and performance is good on my laptop! PalmOS takes around 340 million instructions to initialize and check its internal state and all peripherals. To complete this process, we mimic the peripherals accurately enough that the software can’t tell it is sandboxed. Afterwards, the CPU sleeps (which we need to communicate up the stack to the host OS so it can sleep). Touch events are the first interrupt implemented, and the interrupt most critical to interactivity of the device. (NB: because PalmOS does not multitask, general interaction does not require timer interrupts, so they have not been high on my priority list.)
I ran into an emulator bug with PalmOS shutting down after interrupts. For simplicity earlier, I spoofed some GPIO reads to zero when the initialization process does not depend on realistic values. As it happens, GPIO Port D measures the battery level. PalmOS reads battery level during boot, but does not stop the boot process if the battery level is too low. However, it does check after the first interrupt, so the first touch caused the device to assume it had no battery left and shut down. Now we provide a fake charge level.
There are two more steps to take in the immediate future. One is to implement more interrupts, which has a very concrete “success” outcome. The other is more design-heavy: asynchronous delivery of interrupts. I’ve forgone this for now, because the most performant and power-aware design for my laptop is almost certainly not the right choice for our ESP32-P4 processor running FreeRTOS. (After all, targeting our specific package is a major advantage of writing our own components.) I’ve been sketching this out throughout the week; currently, I plan on sync points between every few instruction executions where we check a queue. I’m eager to play around with a properly async design with multiple tasks, I suspect it won’t be worth performing as an optimization (and could potentially hurt performance) and it would only be worth trying as a learning exercise. We will see!
Having seen comfortable performance margins (despite running on a much more capable core), my assessment of the risk of performance has gone down. I have confidence in my ability to achieve fully performant execution. By the end of Monday, I’ll have complete data about performance on the P4, and will adjust the emulator schedule appropriately. I think storage carries some risk – we are working with finite flash on the device, and I’m worried about the complexity of emulating an SD card to PalmOS – but our current forecasts look good, and we have back-up plans for these problems. On the emulator side, the risks I’m aware of are manageable!
I do not any adjustments to the schedule of emulator work at this time, but will reevaluate depending on performance data.
Earlier this week, we tried to assemble the PCB in the TechSpark PCB Lab. However, we realized several ICs were too small to be soldered on using the equipment we had access to, so we decided to reorder the PCB with most components preassembled.
The GPS module arrived towards the later half of the week, so I also worked on integrating it with the ESP32P4 dev board. The configuration, initialization, NMEA message parsing, and PPS timing support were completed, and the good news is firmware now reports latitude, longitude, altitude, and UTC timestamps. I tested this between Squirrel Hill and campus, and the log showed within 10m horizontal accuracy, which hit our goal. However, during the development, I also noticed the module needs to take several minutes to reacquire location information after a full power-off, which is a bit long and I might want to further look into for a workaround if time allows.
Firmware integration will be delayed by approximately 10 days because of the PCB reorder. To mitigate this, I will continue developing and testing peripheral services on the dev board while waiting.
Next week, I plan to integrate GPS updates into the UI simulator, and after that, the main goal is to create the touchscreen and LoRa firmware scaffolds for later hardware integration.
This is a lighter week for us since we were waiting for a lot of pending delivery. Progress wise, we are transitioning into integration from designing. We’d done an inventory check to make sure all the necessary components have been ordered. The PCB has arrived and we are waiting for the processor to arrive for the initial assembly. We also continued to have improvements to memory access and instruction decoding regarding the emulator development.
The current main risk is PCB bring-up, and the integration afterwards. We will assembly and test the PCB without the modules that haven’t arrived. Once the continuity and power-rail measurements are good, we will test running programs on the PCB. We will also focus on memory access optimization and benchmarking on the emulator since that’s the current performance bottleneck.
We have adjusted the schedule to assembly the PCB early next week to account for its delayed delivery. A couple changes in the design are that the emulator will use a hard-coded chip-select config for performance instead of fully reproducing the original hardware behaviour, and we revised the enclosure design to work with low-profile switches. These are some new design choices and neither affects the core system requirements.
Next week, we will assemble and test the PCB in TechSpark. Once it’s verified to be functional, we will begin peripheral integration and testing on the board and also do more performance benchmarking and optimization on the Pam OS emulator.
This week, I mainly focused on reviewing feedbacks on our design report, as well as working on the ethics assignment. Firmware development slowed down since both the GPS module hasn’t been delivered yet, and I worked on fixing some minor details of the scaffolding. Likewise, we have received the PCB but are still waiting for the hardware components to arrive. We are still roughly on schedule since we have allocated buffer time to account for this delay in delivery in the schedule. The estimated arrival is next week, and the plan is to assemble the PCB and test it, as well as begin the peripheral driver integration on the PCBA afterwards for the interim demo.
A bit of a lighter week due to being in between steps and other obligations outside of this class. The PCB arrived, along with the parts order! I took inventory and made sure we had everything we ordered, including the fabbed boards, components, and stencils. The only components we’re waiting on now are the GPS module and display, but we can still assemble the board next week without these components since both of these are connected via header rather than being soldered onto the board. We adjusted our schedule to account for the PCB being ordered over break rather than before, so we should still be on track to assemble early next week in TechSpark and test powering on the PCB in time for the interim demo. At minimum, I plan to test continuity, as well as plugging it into battery/USB and ensuring that the voltages look fine. If possible, I’ll also coordinate with Maggie to see how much of the peripherals we can begin testing, if any.
Hello again! This week, I kept working on the emulator and have new plans for the housing. We received most of our parts, and will be doing integration soon. Over the next two weeks, my job is to bring up the emulated Palm OS on the dev board, not just on my laptop!
I’ve been refining our model of the m515 components based on areas I know mismatch real hardware and where the PalmOS image stops making progress. One thing that I’m deliberately not faithfully recreating is the chip-select system. This version of PalmOS initially runs without the chip-select system set up (and thus truncates all addresses) and then initializes it to a known pattern (lower half of ram for ephemeral memory, upper half for storage, and a 4MB flash). The only changes after this are write-protecting and un-protecting the storage half of memory, as a rudimentary way to detect accidental writes. (This does not protect against a malicious app, as all programs are run in supervisor mode.) Instead of fully implementing the chip-select system, I hard-code the chip-select configuration for performance.
I measured instruction/data memory time as making up nearly 90% of execution time in warm optimized builds, because the emulator must do an operation for every instruction and data access, and a naïve approach has indirection and branches. (I would like to research what the ratio is in real hardware…) Therefore, my hypothesis that it’s the first place to look for performance improvements is correct! My (yet-to-measure) theories on the best way to optimize: emit separate emulator code for pre-chip-select and post-chip-select code to avoid branches, emit separate code paths for instruction fetches and data read/write, and try catching MMIO accesses with hardware traps instead of a branch (which may be less performant during boot, but I hypothesize that it will be more performant later). We can make a lot of improvements since accurate hardware-timing is a non-goal (and we can always slow it down later if it becomes a goal). More work to come!
We decided to use low-profile low-actuation-distance keyboard key switches for buttons: they’re very easy to source (my house is full of them), very reliable, have a convenient post for mounting a cap, and of course feel great. As a result, the case will have a different button spacing and needs less structure for keeping the buttons captive.
Next week, I’m still working on the emulator, especially on the dev board. Performance continues to be a major risk here, and I’m contemplating setting up more benchmark measurement infrastructure. I’m excited to see how our hardware integration goes!