Parts from LCSC

Being on the EEVblog forum, I saw an ad for a new (at least on the international market) component distributor, LCSC. I went to their website out of pure curiosity, but wanting to get components for my power supply, I went to search for some parts. When I saw the prices compared to eBay (I can’t use Farnell and others since I don’t have a company), i just had to order ūüėÄ

The parts came in a nice box, packaged into individual anti-static bags. It was kinda a WTF-moment when I first saw the package, as it said “PCB Samples”, so I went “Uhh, I didn’t order that?” I kinda find funny what the order value was too (It was the actual order value though)

I hope to order from them again soon, i was really surprised with how fast and cheap it was.

 

This review (or whatever) is not supported, paid or endorsed by LCSC.

Operating system development

Since I was little, I’ve always been interested in operating systems for some reason. When I got started “programming” using Scratch at around the age of 6, I wouldn’t create games. Instead, I would be a part of this Scratch community creating “Operating Systems”. Of course they had not much¬†to do with real operating systems , it was just a “desktop” with some applications, but even though they weren’t useful, and could not be ran standalone, it was a lot of fun doing it back then ( Everything is still here,¬†beware of the cringe).

After I few years I came back to the idea of writing my own OS, this time one that can actually run, and since I got into electronics, mainly microcontrollers I also wanted to learn C. At that time, I have been long running Linux, so setting up a compiling environment was easy (as it turned out later, I actually had no clue) and I just went with a tutorial online, which was actually the first mistake: Never use tutorials. They are usually written by one person ,often inexperienced and can’t be edited by the community, meaning it also comes with all the mistakes. This was enough to get me hooked though, and the same sleepless night I’ve written my first line of code of what was to become Hydrogen. I’ve also found osdev.org, which later turned out to be a goldmine, together with the community on the #osdev channel at freenode on which i tend to hang around pretty often.

Here are some hints and experiences if you want to get into it too:

Hint 0: Don’t look for code

Learn osdev from reputable sources. Use the osdev wiki. Use the osdev forums. Use #osdev. Use the Intel and AMD manuals. Do not follow articles that have not been peer reviewed, or are not community editable.

Hint 1: Read, read, READ

Books are usually really good resources, since they are (usually) written by people that know a lot about a certain subject. As mentioned earlier, the OSdev wiki and community is also a goldmine, and if you are going for something more than “hello world” you are going to¬†find yourself there more than often. I also strongly recommend you stay away from non-community edited tutorials that will often be low-quality, wrong and nobody can correct them!

A good starting point would be this

Hint 2: Write things well

Now, everyone sees “good code” differently, but main point is: Don’t think “I will correct/redo this later, its good enough” because the truth is: You won’t, or it will be really hard (see the next hint) and you will end up doing double/triple work.

Hint 2.5: Don’t leave code behind

If it happens that your coding style from before was bad (it was), don’t leave it behind, correct it instead, it will make life easier for you. It might be something small like “unsigned int” instead of “uint32_t” but it actually matters a lot, and when you have 500 lines of code with that… It’s not fun correcting it.

Hint 4: Don’t skip things.

When I’ve started i used to assume stuff was done for me, for example that memory is 0, hardware has always same settings at boot and i don’t need initialize anything.¬†Turned out i was wrong when my page table had garbage entries.

Hint 5: Be unique

Please, don’t call your system “MyOS”. There are already dozens of these ALL WITH THE SAME NAME. A good example of original naming are: ToaruOS („Ā®„Āā„āčOS), Moonix, ¬†Hydrogen, ¬†Sortix, Glaux, Haiku to name a few. See, it can be done!¬†Yes, ToaruOS is “*OS”, but it is actually a joke on “MyOS”.

Hint 6: Know what you want

Know what you want to get from OSdev, don’t let anything other than you decide what you get out of it.

Hint 7: Don’t overcomplicate stuff

Make things as simple as possible, but no simpler.

Hint 8: Know your enemy

Learn how existing systems work, how other people do things, competing ways of doing it. Make a choice, don’t let someone make it for you. After you’ve done that, learn about the practical implementation of the solution.

 

Some of the above “hints” also apply to programming in general, not OSdev specifically.

I hope this helps someone, OSdev is a hard but fun hobby, and brings you a lot of satisfaction if you are persistent in going forward.

Thanks to sortie for helping me write this.

Designing a switching PSU for Orange Pi

Everyone loves SBCs, right? Right, especially since you can get things like the Orange Pi, that costs only 15 USD for the Orange Pi PC (with some quite impressive specs). This basically enables people to do awesome things like servers, media centers and Linux-based robots without spending a ton of money, which in turn makes these little computers really popular. But popularity doesn’t mean they are perfect. The use of non-standard connectors, no standard size,¬† and most importantly, powering issues. These boards require quite beefy power supplies and at 5V too, so the requirement of a 5V2A or 5V3A power supply is not uncommon with these. Therefore, people usually end up buying these PSUs for the cheapest price possible, from questionable sources, which leads to the board being unstable or not booting. I have had trouble with that myself, especially with finding a cable that was suitable. After a while I’ve designed a little HAT (Hardware Attached on Top) for the Orange Pi, called “md-psuhat”.

It was a bad design, had large hot loops and was emitting a lot of noise because i had no clue about switching PSU design. After having that pointed out to me by someone in the Orange Pi group on Facebook, I’ve began working on a new design (Based on the same chip, LM2596). Other than improving the circuit, I’ve also made the following improvements:

  • Used a stackable header, so that i don’t loose GPIO when the HAT is in place.
  • Extended the PCB and added matching holes so I can mount it on spacers for stability.
  • Used a shielded inductor for less EMI

What i ended up is this:

The finished board on top of a OPi PC+

It was a great learning experience, especially getting the LM2596 to work properly. Turns out that switching PSUs need a load, otherwise you can destroy the chip (I have ruined 3 before figuring out what it was). I am also going to do other sizes, for other SBCs. I also wanna replace the DC jack with a SMD one, and have a terminal block for power, along with some other improvements. Here are the files for the current version (Designed in KiCAD):

https://drive.google.com/open?id=0B5goNLARJa4fTTk4YXZlb0lFLU0

(sorry for Google Drive, will put it up on my server soon)

 

ATX in a rack case – Part 1

What do you do with an old, loud rack Ethernet switch? Convert it to a server of course!

I’ve had an old rack switch lying around (Planet brand IIRC), since I was planning to use it. But because it’s so loud, big and power-hungry, I’ve scrapped the idea and I am looking to a better one for my rack. Instead of just throwing out the switch, my dad suggested we could convert it to ATX and have it run with standard PC components. So we did, and this is what we’ve ended up with:

The server before being closed and installed in a rack.

A little bit about the construction of it:

The first problem we’ve faced was: How are we gonna power it? Getting one of these “PicoPSU” modules would mean buying something¬† – we wanted to avoid that and use parts already on hand, so we tried fitting a standard ATX PSU in there, but it was too high (The case is 1.5U). We’ve¬† had a server PSU, but it wasn’t ATX, so… we converted it of course! When I took the PSU apart, it turned out that the connections silk-screened on the PSUs PCB are actually mostly ATX connections.

The server

That actually makes a lot of sense, since why would anyone design a new standard for PSUs? Doing that would mean you also need to make the hardware work with your new thing. This makes me think that there should be more of these “convertible” PSUs out there, which would be great for projects like this one (And perhaps for slim-ish lab PSUs?).

After getting the power sorted out, the next challenge we’ve faced was cooling the processor.¬† It’s quite power-hungry, at 65W (still nothing compared to my FX8350, 125W), so it requires quite some cooling. We considered laptop cooling at first because the stock cooler with the fan on top wouldn’t fit the case, but we ended up using the stock cooler without the top fan, having fans blowing from the side instead. I was worried the temperatures may be too high to run it like that, but Prime95 torture tests really surprised me, showing only 70 degrees celsius under maximum load with the case closed, which is pretty awesome I think.

Having the mounting part out of the way, all there was left was installing the HDD caddy and buttons/LEDs for power-on and other things (pulled out of an old PC case). There is no front panel yet, but that will make Part 2, where i will make one from everyone’s favourite material, FR4! (The stuff you make PCBs from)

Some detailed specs:

  • Intel DG33TL Desktop Board
  • Intel Core 2 Duo E6600 CPU
  • 4 GiB of DDR2 RAM (Can’t recall the frequency)
  • 640 GB HDD
  • AcBel¬†API0FS51 200W PSU (Spec sheet here: goo.gl/apDJy7)
The server installed in my rack (excuse the quality)