For me it worked well with Kitharologus tremolo exercises.
Start tremolo as multiple of 3, with formula pimami and pamima.
Play tremolo on first string while thumb on all the others. Also play thumb 6th string and tremolo change from strings 1 to 4 each time.
When pimami and pamima are even and at good speed, change to pami and pima (regular tremolo), but also interchange with:
(p together with m, so the tremolo is not interrupted by p and you can work on evennes of interval between p and ami or ima).
Also practiced from pp to ff and with preparation/staccato or legato.
Then started playing easier pieces like Carcassi etude, Ponce Prelude and Viñas Sueño.
On the problem of playing tremolo over B or G strings, this is about good hand positioning etc. When I started playing it was solved in the first couple lessons with teacher guidance on good hand positioning and the best ways of doing it. If I needed to solve this alone, I would probably take months to find the right way, if ever.
I also only started practicing it when RH was already good enough, playing with good realxation, good sound production and evenness. The teacher wouldn't allow starting tremolo before basics were ready.